Skip to content

Commit 4e738e2

Browse files
committed
Fix HF_ENDPOINT not handled correctly (#2155)
1 parent 4ecdbee commit 4e738e2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/huggingface_hub/hf_api.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,6 @@ def repo_type_and_id_from_hf_id(hf_id: str, hub_url: Optional[str] = None) -> Tu
185185
"""
186186
input_hf_id = hf_id
187187

188-
# check if a proxy has been set => if yes, update the returned URL to use the proxy
189-
if ENDPOINT not in (_HF_DEFAULT_ENDPOINT, _HF_DEFAULT_STAGING_ENDPOINT):
190-
hf_id = hf_id.replace(_HF_DEFAULT_ENDPOINT, ENDPOINT)
191-
hf_id = hf_id.replace(_HF_DEFAULT_STAGING_ENDPOINT, ENDPOINT)
192-
193188
hub_url = re.sub(r"https?://", "", hub_url if hub_url is not None else ENDPOINT)
194189
is_hf_url = hub_url in hf_id and "@" not in hf_id
195190

@@ -436,6 +431,11 @@ class RepoUrl(str):
436431
"""
437432

438433
def __new__(cls, url: Any, endpoint: Optional[str] = None):
434+
# check if a proxy has been set => if yes, update the returned URL to use the proxy
435+
if ENDPOINT not in (_HF_DEFAULT_ENDPOINT, _HF_DEFAULT_STAGING_ENDPOINT):
436+
url = url.replace(_HF_DEFAULT_ENDPOINT, ENDPOINT)
437+
url = url.replace(_HF_DEFAULT_STAGING_ENDPOINT, ENDPOINT)
438+
439439
return super(RepoUrl, cls).__new__(cls, url)
440440

441441
def __init__(self, url: Any, endpoint: Optional[str] = None) -> None:

0 commit comments

Comments
 (0)