From 53ec95b87e84ad295d2387e8c461371c7b3495df Mon Sep 17 00:00:00 2001 From: Talmaj Marinc Date: Tue, 30 Jun 2026 09:41:40 +0200 Subject: [PATCH] Improve normalize_host --- app/model_downloader/credentials/store.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/model_downloader/credentials/store.py b/app/model_downloader/credentials/store.py index 8f4a0cda7..c2023ccdc 100644 --- a/app/model_downloader/credentials/store.py +++ b/app/model_downloader/credentials/store.py @@ -11,6 +11,7 @@ from __future__ import annotations import asyncio from dataclasses import dataclass from typing import Optional +from urllib.parse import urlsplit from app.model_downloader.constants import ( AUTH_SCHEME_BEARER, @@ -26,7 +27,10 @@ def normalize_host(host: str) -> str: """Lowercase, strip port, IDNA-encode.""" if not host: 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 host = host[1 : host.index("]")] elif host.count(":") == 1: # host:port (not IPv6)