refactor(openclaw): reuse shared gateway url validation
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -1,30 +1,11 @@
|
||||
import { spawn } from "bun"
|
||||
import { validateGatewayUrl } from "./config"
|
||||
import type { OpenClawGateway, WakeResult } from "./types"
|
||||
|
||||
const DEFAULT_HTTP_TIMEOUT_MS = 10_000
|
||||
const DEFAULT_COMMAND_TIMEOUT_MS = 5_000
|
||||
const MIN_COMMAND_TIMEOUT_MS = 100
|
||||
const MAX_COMMAND_TIMEOUT_MS = 300_000
|
||||
const SHELL_METACHAR_RE = /[|&;><`$()]/
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
export function interpolateInstruction(
|
||||
template: string,
|
||||
|
||||
Reference in New Issue
Block a user