Skip to content

Commit

Permalink
update quote_url (#439)
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Zhang <jack4zhang@gmail.com>
Fix #417
  • Loading branch information
zhan9san authored Feb 10, 2024
1 parent 2e92742 commit 86ed353
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions artifactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,13 @@ def quote_url(url):
parsed_url = urllib3.util.parse_url(url)
if parsed_url.port:
quoted_path = requests.utils.quote(
url.rpartition(f"{parsed_url.host}:{parsed_url.port}")[2]
url.partition(f"{parsed_url.host}:{parsed_url.port}")[2]
)
quoted_url = (
f"{parsed_url.scheme}://{parsed_url.host}:{parsed_url.port}{quoted_path}"
)
else:
quoted_path = requests.utils.quote(url.rpartition(parsed_url.host)[2])
quoted_path = requests.utils.quote(url.partition(parsed_url.host)[2])
quoted_url = f"{parsed_url.scheme}://{parsed_url.host}{quoted_path}"

return quoted_url
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/test_artifactory_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ def test_quote_url(self):
check(
"https://example.com/artifactory/foo", "https://example.com/artifactory/foo"
)
check(
"https://example.com/artifactory/foo/example.com/bar",
"https://example.com/artifactory/foo/example.com/bar"
)
check(
"https://example.com/artifactory/foo/#1",
"https://example.com/artifactory/foo/%231",
Expand Down

0 comments on commit 86ed353

Please sign in to comment.