export function isPathInScope(pathname, base) { let canonical; try { const pre = pathname.replace(/%2f/gi, "/").replace(/%5c/gi, "\\"); canonical = new URL(pre, "http://_").pathname; } catch { return false; } return !base || canonical === base || canonical.startsWith(base + "/"); }