mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 17:34:58 +00:00
refactor: centralize isPlainObject, isRecord, isErrno, isLoopbackHost utilities (#12926)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { isLoopbackHost } from "./net.js";
|
||||
|
||||
type OriginCheckResult = { ok: true } | { ok: false; reason: string };
|
||||
|
||||
function normalizeHostHeader(hostHeader?: string): string {
|
||||
@@ -38,22 +40,6 @@ function parseOrigin(
|
||||
}
|
||||
}
|
||||
|
||||
function isLoopbackHost(hostname: string): boolean {
|
||||
if (!hostname) {
|
||||
return false;
|
||||
}
|
||||
if (hostname === "localhost") {
|
||||
return true;
|
||||
}
|
||||
if (hostname === "::1") {
|
||||
return true;
|
||||
}
|
||||
if (hostname === "127.0.0.1" || hostname.startsWith("127.")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function checkBrowserOrigin(params: {
|
||||
requestHost?: string;
|
||||
origin?: string;
|
||||
|
||||
Reference in New Issue
Block a user