refactor(openclaw): extract gateway url validator

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-04-11 22:49:15 +09:00
parent 21822ba29f
commit a2ae3de31a
3 changed files with 20 additions and 20 deletions
+1 -19
View File
@@ -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
}
}
+1 -1
View File
@@ -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
+18
View File
@@ -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
}
}