From f95e7a6c6b734aa4d234da2d462a668abc6350f9 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Sat, 11 Apr 2026 22:29:14 +0900 Subject: [PATCH] refactor(openclaw): reuse shared gateway url validation Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- src/openclaw/dispatcher.ts | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/src/openclaw/dispatcher.ts b/src/openclaw/dispatcher.ts index 173819c93..7c777a39e 100644 --- a/src/openclaw/dispatcher.ts +++ b/src/openclaw/dispatcher.ts @@ -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,