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)

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`.
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
 

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y gcc
3.9
requirements-dev.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
certifi==2025.1.31
charset-normalizer==3.4.1
-e git+https://github.com/devopshq/artifactory.git@b63e93ff509fd1d4ba619d7db2d3abab02624e32#egg=dohq_artifactory
exceptiongroup==1.2.2
flake8==7.2.0
idna==3.10
iniconfig==2.1.0
mccabe==0.7.0
mock==5.2.0
packaging==24.2
pathlib==1.0.1
pluggy==1.5.0
pycodestyle==2.13.0
pyflakes==3.3.2
pytest==8.3.5
python-dateutil==2.9.0.post0
requests==2.32.3
six==1.17.0
tomli==2.2.1
urllib3==2.3.0

name: artifactory
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - exceptiongroup==1.2.2
      - flake8==7.2.0
      - idna==3.10
      - iniconfig==2.1.0
      - mccabe==0.7.0
      - mock==5.2.0
      - packaging==24.2
      - pathlib==1.0.1
      - pluggy==1.5.0
      - pycodestyle==2.13.0
      - pyflakes==3.3.2
      - pytest==8.3.5
      - python-dateutil==2.9.0.post0
      - requests==2.32.3
      - six==1.17.0
      - tomli==2.2.1
      - urllib3==2.3.0
prefix: /opt/conda/envs/artifactory

tests/unit/test_artifactory_path.py::ArtifactoryFlavorTest::test_splitroot_custom_drv
tests/unit/test_artifactory_path.py::UtilTest::test_escape_chars tests/unit/test_artifactory_path.py::UtilTest::test_matrix_encode tests/unit/test_artifactory_path.py::UtilTest::test_properties_encode tests/unit/test_artifactory_path.py::UtilTest::test_properties_encode_multi tests/unit/test_artifactory_path.py::ArtifactoryFlavorTest::test_parse_parts tests/unit/test_artifactory_path.py::ArtifactoryFlavorTest::test_splitroot tests/unit/test_artifactory_path.py::ArtifactoryFlavorTest::test_splitroot_custom_root tests/unit/test_artifactory_path.py::PureArtifactoryPathTest::test_anchor tests/unit/test_artifactory_path.py::PureArtifactoryPathTest::test_join_endswith_slash tests/unit/test_artifactory_path.py::PureArtifactoryPathTest::test_join_endswithout_slash tests/unit/test_artifactory_path.py::PureArtifactoryPathTest::test_join_with_repo tests/unit/test_artifactory_path.py::PureArtifactoryPathTest::test_join_with_repo_folder tests/unit/test_artifactory_path.py::PureArtifactoryPathTest::test_root tests/unit/test_artifactory_path.py::PureArtifactoryPathTest::test_with_suffix tests/unit/test_artifactory_path.py::ArtifactoryAccessorTest::test_deploy tests/unit/test_artifactory_path.py::ArtifactoryAccessorTest::test_get_properties tests/unit/test_artifactory_path.py::ArtifactoryAccessorTest::test_listdir tests/unit/test_artifactory_path.py::ArtifactoryAccessorTest::test_mkdir tests/unit/test_artifactory_path.py::ArtifactoryAccessorTest::test_set_properties tests/unit/test_artifactory_path.py::ArtifactoryAccessorTest::test_set_properties_without_remove tests/unit/test_artifactory_path.py::ArtifactoryAccessorTest::test_stat tests/unit/test_artifactory_path.py::ArtifactoryPathTest::test_auth tests/unit/test_artifactory_path.py::ArtifactoryPathTest::test_auth_inheritance tests/unit/test_artifactory_path.py::ArtifactoryPathTest::test_basic tests/unit/test_artifactory_path.py::ArtifactoryPathTest::test_path_in_repo tests/unit/test_artifactory_path.py::ArtifactoryPathTest::test_repo tests/unit/test_artifactory_path.py::TestArtifactoryConfig::test_artifactory_config tests/unit/test_artifactory_path.py::TestArtifactoryAql::test_create_aql_text_list tests/unit/test_artifactory_path.py::TestArtifactoryAql::test_create_aql_text_list_in_dict tests/unit/test_artifactory_path.py::TestArtifactoryAql::test_create_aql_text_simple tests/unit/test_artifactory_path.py::TestArtifactoryAql::test_from_aql_file
artifactory.py
artifactory.py