re
Some checks failed
smoke-mm / Install & smoke test mm --help (push) Has been cancelled
Some checks failed
smoke-mm / Install & smoke test mm --help (push) Has been cancelled
This commit is contained in:
30
metadata.py
30
metadata.py
@@ -395,32 +395,10 @@ def normalize_urls(value: Any) -> List[str]:
|
||||
if not u:
|
||||
return None
|
||||
|
||||
lower = u.lower()
|
||||
if not (lower.startswith("http://") or lower.startswith("https://")):
|
||||
return u
|
||||
|
||||
try:
|
||||
parsed = urlsplit(u)
|
||||
except Exception:
|
||||
return u
|
||||
|
||||
scheme = (parsed.scheme or "").lower()
|
||||
netloc = (parsed.netloc or "").lower()
|
||||
path = unquote(parsed.path or "")
|
||||
query = parsed.query or ""
|
||||
|
||||
# Normalize default ports.
|
||||
if scheme == "http" and netloc.endswith(":80"):
|
||||
netloc = netloc[:-3]
|
||||
elif scheme == "https" and netloc.endswith(":443"):
|
||||
netloc = netloc[:-4]
|
||||
|
||||
# Prefer no trailing slash except root.
|
||||
if path and path != "/":
|
||||
path = path.rstrip("/")
|
||||
|
||||
# Fragments are not part of the resource.
|
||||
return urlunsplit((scheme, netloc, path, query, ""))
|
||||
# IMPORTANT: URLs can be case-sensitive in the path/query on some hosts
|
||||
# (e.g., https://0x0.st/PzGY.webp). Do not lowercase or otherwise rewrite
|
||||
# the URL here; preserve exact casing and percent-encoding.
|
||||
return u
|
||||
|
||||
seen: Set[str] = set()
|
||||
out: List[str] = []
|
||||
|
||||
Reference in New Issue
Block a user