Skip to content

Commit 8172137

Browse files
committed
More robust storage host check
1 parent 305e05b commit 8172137

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/neuromaps_prime/fetcher.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from pathlib import Path
44
from typing import Literal
5+
from urllib.parse import urlparse
56

67
from neuromaps_prime.remote import OSFStorage
78

@@ -15,8 +16,15 @@ def id_storage(uri: str) -> Literal["osf"] | None:
1516
Returns:
1617
String indicating type of storage (one of 'osf')
1718
"""
18-
if "osf.io" in uri:
19-
return "osf"
19+
20+
def _find_host(storage: str, host: str) -> bool:
21+
return storage == host or host.endswith(storage)
22+
23+
host = urlparse(uri).hostname
24+
if host is not None:
25+
host = host.lower()
26+
if _find_host(storage="osf.io", host=host):
27+
return "osf"
2028
return None
2129

2230

0 commit comments

Comments
 (0)