/** Read a Host authority with the platform URL parser; bracketed IPv6 retains its address. */ export function readHostPort(authority: string): { host: string; port: string } | undefined { try { if (!authority || /[\s/\\?#@]/.test(authority)) return undefined; const url = new URL(`http://${authority}`); if (url.username || url.password) return undefined; return { host: url.hostname.toLowerCase(), port: url.port }; } catch { return undefined; } }