export function isInternal(base, candidate) { try { const baseUrl = new URL(base); const testUrl = new URL(candidate, base); const protocolOk = testUrl.protocol === "http:" || testUrl.protocol === "https:"; const stripWWW = (h) => h.replace(/^www\./i, ""); return protocolOk && stripWWW(baseUrl.hostname) === stripWWW(testUrl.hostname); } catch { return false; } }