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

Fix #53: Handle trailing slashes in jellyfin_url #54

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion jellyfin_apiclient_python/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@


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


def basic_info():
Expand Down
13 changes: 13 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from jellyfin_apiclient_python.api import jellyfin_url
from unittest.mock import Mock

def test_jellyfin_url_handles_trailing_slash():
mock_client = Mock()
mock_client.config.data = {'auth.server': 'https://example.com/'}
handler = "Items/1234"
url = jellyfin_url(mock_client, handler)
assert url == "https://example.com/Items/1234"

mock_client.config.data = {'auth.server': 'https://example.com'}
url = jellyfin_url(mock_client, handler)
assert url == "https://example.com/Items/1234"