diff --git a/src/openclaw/config.ts b/src/openclaw/config.ts index 846f6d912..c501f5c8d 100644 --- a/src/openclaw/config.ts +++ b/src/openclaw/config.ts @@ -3,6 +3,7 @@ import type { OpenClawGateway, OpenClawReplyListenerConfig, } from "./types" +export { validateGatewayUrl } from "./gateway-url-validation" const DEFAULT_REPLY_POLL_INTERVAL_MS = 3000 const MIN_REPLY_POLL_INTERVAL_MS = 500 @@ -97,22 +98,3 @@ export function resolveGateway( return { gatewayName: mapping.gateway, gateway, instruction: mapping.instruction } } - -export function validateGatewayUrl(url: string): boolean { - try { - const parsed = new URL(url) - if (parsed.protocol === "https:") return true - if ( - parsed.protocol === "http:" && - (parsed.hostname === "localhost" || - parsed.hostname === "127.0.0.1" || - parsed.hostname === "::1" || - parsed.hostname === "[::1]") - ) { - return true - } - return false - } catch { - return false - } -} diff --git a/src/openclaw/dispatcher.ts b/src/openclaw/dispatcher.ts index 7c777a39e..5971f371d 100644 --- a/src/openclaw/dispatcher.ts +++ b/src/openclaw/dispatcher.ts @@ -1,5 +1,5 @@ import { spawn } from "bun" -import { validateGatewayUrl } from "./config" +import { validateGatewayUrl } from "./gateway-url-validation" import type { OpenClawGateway, WakeResult } from "./types" const DEFAULT_HTTP_TIMEOUT_MS = 10_000 diff --git a/src/openclaw/gateway-url-validation.ts b/src/openclaw/gateway-url-validation.ts new file mode 100644 index 000000000..4d37be9df --- /dev/null +++ b/src/openclaw/gateway-url-validation.ts @@ -0,0 +1,18 @@ +export function validateGatewayUrl(url: string): boolean { + try { + const parsed = new URL(url) + if (parsed.protocol === "https:") return true + if ( + parsed.protocol === "http:" && + (parsed.hostname === "localhost" || + parsed.hostname === "127.0.0.1" || + parsed.hostname === "::1" || + parsed.hostname === "[::1]") + ) { + return true + } + return false + } catch { + return false + } +}