mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 14:48:28 +00:00
fix(browser): handle IPv6 loopback auth and dedupe fetch auth tests
This commit is contained in:
@@ -21,7 +21,11 @@ function isAbsoluteHttp(url: string): boolean {
|
||||
function isLoopbackHttpUrl(url: string): boolean {
|
||||
try {
|
||||
const host = new URL(url).hostname.trim().toLowerCase();
|
||||
return host === "127.0.0.1" || host === "localhost" || host === "::1";
|
||||
// URL hostnames may keep IPv6 brackets (for example "[::1]"); normalize before checks.
|
||||
const normalizedHost = host.startsWith("[") && host.endsWith("]") ? host.slice(1, -1) : host;
|
||||
return (
|
||||
normalizedHost === "127.0.0.1" || normalizedHost === "localhost" || normalizedHost === "::1"
|
||||
);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user