Repository: devopshq/artifactory

Issue:
ArtifactoryPath returns incorrect path if URL doesn't contain artifactory outside of domain
The `ArtifactoryPath` method returns an incorrect value if the string passed to it doesn't contain the word `artifactory` somewhere outside of the domain.

For example, if setting up Artifactory behind NGINX with a custom domain, then you have the following behavior:

```python
path = ArtifactoryPath("http://af.demo.local/gradle-ivy-local")
print(path)
```
Returns `http:/af.demo.local/gradle-ivy-local` (notice just the once forwards slash at the scheme level)

Using `path = ArtifactoryPath("http://artifactory.demo.local/gradle-ivy-local")` returns `http:/artifactory.demo.local/gradle-ivy-local` (still just one forward slash).

If you add `artifactory` somewhere in the URL (doesn't really matter where) then the path resolves correctly.

For example using `path = ArtifactoryPath("http://artifactory.demo.local/gradle-ivy-local/artifactory")` returns `http://artifactory.demo.local/gradle-ivy-local/artifactory`.

Discussion:

Patch:
diff --git a/artifactory.py b/artifactory.py
index 48547ec..3b14d4f 100755
--- a/artifactory.py
+++ b/artifactory.py
@@ -344,6 +344,10 @@ class _ArtifactoryFlavour(pathlib._Flavour):
         before it, including '/artifactory/' itself is treated as drive.
         The next folder is treated as root, and everything else is taken
         for relative path.
+
+        If '/artifactory/' is not in the URI. Everything before the path
+        component is treated as drive. The first folder of the path is
+        treated as root, and everything else is taken for relative path.
         """
         drv = ''
         root = ''
@@ -353,8 +357,20 @@ class _ArtifactoryFlavour(pathlib._Flavour):
             mark = without_http_prefix(base).rstrip(sep) + sep
             parts = part.split(mark)
         else:
-            mark = sep + 'artifactory' + sep
-            parts = part.split(mark)
+            url = urllib3.util.parse_url(part)
+            if url.path is None or url.path == sep:
+                if url.scheme:
+                    return part.rstrip(sep), '', ''
+                return '', '', part
+            elif 'artifactory' in url.path:
+                mark = sep + 'artifactory' + sep
+                parts = part.split(mark)
+            else:
+                drv = part.split(url.path)[0]
+                path_parts = url.path.strip(sep).split(sep)
+                root = sep + path_parts[0] + sep
+                rest = sep.join(path_parts[1:])
+                return drv, root, rest
 
         if len(parts) >= 2:
             drv = parts[0] + mark.rstrip(sep)


Test patch:
diff --git a/tests/unit/test_artifactory_path.py b/tests/unit/test_artifactory_path.py
index 4405b3b..0460d7f 100644
--- a/tests/unit/test_artifactory_path.py
+++ b/tests/unit/test_artifactory_path.py
@@ -89,6 +89,37 @@ class ArtifactoryFlavorTest(unittest.TestCase):
         check("https://artifactory.a.b.c.d/artifactory/foo/bar",
               ('https://artifactory.a.b.c.d/artifactory', '/foo/', 'bar'))
 
+    def test_splitroot_custom_drv(self):
+        """
+        https://github.com/devopshq/artifactory/issues/31
+        """
+        check = self._check_splitroot
+
+        check("https://artifactory.example.com",
+              ('https://artifactory.example.com', '', ''))
+        check("https://artifactory.example.com/",
+              ('https://artifactory.example.com', '', ''))
+        check("https://artifactory.example.com/root",
+              ('https://artifactory.example.com', '/root/', ''))
+        check("https://artifactory.example.com/root/",
+              ('https://artifactory.example.com', '/root/', ''))
+        check("https://artifactory.example.com/root/parts",
+              ('https://artifactory.example.com', '/root/', 'parts'))
+        check("https://artifactory.example.com/root/parts/",
+              ('https://artifactory.example.com', '/root/', 'parts'))
+        check("https://artifacts.example.com",
+              ('https://artifacts.example.com', '', ''))
+        check("https://artifacts.example.com/",
+              ('https://artifacts.example.com', '', ''))
+        check("https://artifacts.example.com/root",
+              ('https://artifacts.example.com', '/root/', ''))
+        check("https://artifacts.example.com/root/",
+              ('https://artifacts.example.com', '/root/', ''))
+        check("https://artifacts.example.com/root/parts",
+              ('https://artifacts.example.com', '/root/', 'parts'))
+        check("https://artifacts.example.com/root/parts/",
+              ('https://artifacts.example.com', '/root/', 'parts'))
+
     def test_splitroot_custom_root(self):
         check = self._check_splitroot