Skip to content

Commit

Permalink
fix(transport): when path is empty string don't add an extra "/"
Browse files Browse the repository at this point in the history
Fixes: #17
  • Loading branch information
piraz committed Jun 21, 2024
1 parent a28e736 commit 9d77511
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion peasant/client/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def concat_url(url: str, path: str = None, **kwargs: dict) -> str:
f"Not {type(query_string)}")
raise TypeError(err)
path = f"{path}?{query_string}"
if path is not None and path != "/":
if path is not None and path != "" and path != "/":
if path.startswith("/"):
path = path[1:]
url = f"{url}/{path}"
Expand Down
5 changes: 5 additions & 0 deletions tests/transport_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ def test_concat_url(self):
expected_url = "http://bastion"
self.assertEqual(expected_url, url)

bastion_address = fix_address("http://bastion/")
url = concat_url(bastion_address, "")
expected_url = "http://bastion"
self.assertEqual(expected_url, url)

url = concat_url(bastion_address, path="resource")
expected_url = "http://bastion/resource"
self.assertEqual(expected_url, url)
Expand Down

0 comments on commit 9d77511

Please sign in to comment.