mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 15:35:03 +00:00
refactor: centralize isPlainObject, isRecord, isErrno, isLoopbackHost utilities (#12926)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { isLoopbackHost } from "../gateway/net.js";
|
||||
|
||||
type HostSource = string | null | undefined;
|
||||
|
||||
type CanvasHostUrlParams = {
|
||||
@@ -9,23 +11,6 @@ type CanvasHostUrlParams = {
|
||||
scheme?: "http" | "https";
|
||||
};
|
||||
|
||||
const isLoopbackHost = (value: string) => {
|
||||
const normalized = value.trim().toLowerCase();
|
||||
if (!normalized) {
|
||||
return false;
|
||||
}
|
||||
if (normalized === "localhost") {
|
||||
return true;
|
||||
}
|
||||
if (normalized === "::1") {
|
||||
return true;
|
||||
}
|
||||
if (normalized === "0.0.0.0" || normalized === "::") {
|
||||
return true;
|
||||
}
|
||||
return normalized.startsWith("127.");
|
||||
};
|
||||
|
||||
const normalizeHost = (value: HostSource, rejectLoopback: boolean) => {
|
||||
if (!value) {
|
||||
return "";
|
||||
|
||||
Reference in New Issue
Block a user