Spaces:
Running
Running
File size: 682 Bytes
a6ec759 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | """Small helpers for operational logs that must not expose credentials."""
from urllib.parse import urlsplit
def redacted_endpoint(value) -> str:
raw = str(value or "").strip()
if not raw:
return "missing"
try:
parsed = urlsplit(raw)
if not parsed.scheme or not parsed.hostname:
return "configured (details redacted)"
host = parsed.hostname
if ":" in host and not host.startswith("["):
host = f"[{host}]"
port = f":{parsed.port}" if parsed.port is not None else ""
return f"{parsed.scheme}://{host}{port}"
except (TypeError, ValueError):
return "configured (details redacted)"
|