mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-07-06 22:51:18 +08:00
Improve normalize_host
This commit is contained in:
parent
36c9ef767e
commit
8deef98cc8
@ -11,6 +11,7 @@ from __future__ import annotations
|
|||||||
import asyncio
|
import asyncio
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
from urllib.parse import urlsplit
|
||||||
|
|
||||||
from app.model_downloader.constants import (
|
from app.model_downloader.constants import (
|
||||||
AUTH_SCHEME_BEARER,
|
AUTH_SCHEME_BEARER,
|
||||||
@ -26,7 +27,10 @@ def normalize_host(host: str) -> str:
|
|||||||
"""Lowercase, strip port, IDNA-encode."""
|
"""Lowercase, strip port, IDNA-encode."""
|
||||||
if not host:
|
if not host:
|
||||||
return ""
|
return ""
|
||||||
host = host.strip().lower()
|
host = host.strip()
|
||||||
|
if "://" in host: # a full URL was pasted — extract just the host
|
||||||
|
host = urlsplit(host).hostname or ""
|
||||||
|
host = host.lower()
|
||||||
if host.startswith("[") and "]" in host: # bracketed IPv6 literal
|
if host.startswith("[") and "]" in host: # bracketed IPv6 literal
|
||||||
host = host[1 : host.index("]")]
|
host = host[1 : host.index("]")]
|
||||||
elif host.count(":") == 1: # host:port (not IPv6)
|
elif host.count(":") == 1: # host:port (not IPv6)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user