From 14ea14441c5c9b2e23048cec0f5e01324795c46f Mon Sep 17 00:00:00 2001
From: Jack Zhang <jack4zhang@gmail.com>
Date: Fri, 29 Dec 2023 17:23:50 +0800
Subject: [PATCH] update quote_url

Signed-off-by: Jack Zhang <jack4zhang@gmail.com>
---
 artifactory.py                      | 4 ++--
 tests/unit/test_artifactory_path.py | 4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/artifactory.py b/artifactory.py
index 4325018..69bc540 100755
--- a/artifactory.py
+++ b/artifactory.py
@@ -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
diff --git a/tests/unit/test_artifactory_path.py b/tests/unit/test_artifactory_path.py
index f2f57d9..16e528d 100644
--- a/tests/unit/test_artifactory_path.py
+++ b/tests/unit/test_artifactory_path.py
@@ -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",