Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Malformed URLs caused by trailing slash in auth.server #53

Open
alexhopeoconnor opened this issue Nov 15, 2024 · 0 comments · May be fixed by #54
Open

Malformed URLs caused by trailing slash in auth.server #53

alexhopeoconnor opened this issue Nov 15, 2024 · 0 comments · May be fixed by #54

Comments

@alexhopeoconnor
Copy link

Description:

When configuring the auth.server URL with a trailing slash (e.g., https://example.com/), API calls generate malformed URLs containing double slashes (//). This breaks operations like fetching thumbnails, where the resulting URLs are incorrect and fail to load.

Steps to Reproduce:

  1. Configure auth.server with a trailing slash (https://example.com/).
  2. Fetch media thumbnails or other API resources.
  3. Observe the generated URL contains a double slash, e.g., https://example.com//Items/....

Expected Behavior: The generated URL should be correctly formatted as https://example.com/Items/..., without double slashes.

Proposed Fix: The issue is resolved by sanitizing both the base URL and the handler in the jellyfin_url function. The updated implementation is as follows:

def jellyfin_url(client, handler):
    base_url = client.config.data['auth.server'].rstrip('/')
    return f"{base_url}/{handler.lstrip('/')}"

This ensures:

  • No trailing slash in the base URL.
  • No leading slash in the handler.
  • The final URL is properly constructed with exactly one / between components.

Additional Context: The fix ensures robust URL generation regardless of user configuration.

alexhopeoconnor added a commit to alexhopeoconnor/jellyfin-apiclient-python that referenced this issue Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant