Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
fix(security): resolve CodeQL ReDoS + URL sanitization alerts
diegosouzapwa45d9190dbb7
diff --git a/@omniroute/opencode-provider/src/index.ts b/@omniroute/opencode-provider/src/index.tsindex 92fac28390..b1c2c783fa 100644--- a/@omniroute/opencode-provider/src/index.ts+++ b/@omniroute/opencode-provider/src/index.ts@@ -107,7 +107,10 @@ export function normalizeBaseURL(rawBaseURL: string): string {`@omniroute/opencode-provider: baseURL is not a valid URL: ${JSON.stringify(rawBaseURL)}`);}- return trimmed.replace(/\/+$/, "").replace(/\/v1$/, "") + "/v1";+ let base = trimmed;+ while (base.endsWith("/")) base = base.slice(0, -1);+ if (base.endsWith("/v1")) base = base.slice(0, -3);+ return base + "/v1";}/**diff --git a/bin/cli/api.mjs b/bin/cli/api.mjsindex fd8ac397e0..62564f0103 100644--- a/bin/cli/api.mjs+++ b/bin/cli/api.mjs@@ -45,7 +45,9 @@ export function getBaseUrl(opts = {}) {}function stripTrailingSlash(value) {- return String(value).replace(/\/+$/, "");+ let s = String(value);+ while (s.endsWith("/")) s = s.slice(0, -1);+ return s;}function resolveUrl(path, opts) {diff --git a/src/lib/cli-helper/config-generator/claude.ts b/src/lib/cli-helper/config-generator/claude.tsindex 488f72eeaa..92bb8a7944 100644--- a/src/lib/cli-helper/config-generator/claude.ts+++ b/src/lib/cli-helper/config-generator/claude.ts@@ -8,7 +8,9 @@ export function generateClaudeConfig(options: {apiKey: string;model?: string;}): string {- const base = options.baseUrl.replace(/\/+$/, "").replace(/\/v1$/, "");+ let base = options.baseUrl;+ while (base.endsWith("/")) base = base.slice(0, -1);+ if (base.endsWith("/v1")) base = base.slice(0, -3);const model = options.model || "claude-3-5-sonnet-20241022";const config = {diff --git a/src/lib/cli-helper/config-generator/cline.ts b/src/lib/cli-helper/config-generator/cline.tsindex 5c5bc78765..c0d37e53b9 100644--- a/src/lib/cli-helper/config-generator/cline.ts+++ b/src/lib/cli-helper/config-generator/cline.ts@@ -8,7 +8,9 @@ export function generateClineConfig(options: {apiKey: string;model?: string;}): string {- const base = options.baseUrl.replace(/\/+$/, "").replace(/\/v1$/, "");+ let base = options.baseUrl;+ while (base.endsWith("/")) base = base.slice(0, -1);+ if (base.endsWith("/v1")) base = base.slice(0, -3);const config = {openAiBaseUrl: `${base}/v1`,diff --git a/src/lib/cli-helper/config-generator/codex.ts b/src/lib/cli-helper/config-generator/codex.tsindex 4ec669e483..ca5a1dc815 100644--- a/src/lib/cli-helper/config-generator/codex.ts+++ b/src/lib/cli-helper/config-generator/codex.ts@@ -17,7 +17,9 @@ export async function generateCodexConfig(options: {model?: string;}): Promise<string> {const y = await loadYaml();- const base = options.baseUrl.replace(/\/+$/, "").replace(/\/v1$/, "");+ let base = options.baseUrl;+ while (base.endsWith("/")) base = base.slice(0, -1);+ if (base.endsWith("/v1")) base = base.slice(0, -3);const config = {openai: {diff --git a/src/lib/cli-helper/config-generator/continue.ts b/src/lib/cli-helper/config-generator/continue.tsindex 8eedb4afcf..4eeb6d9c85 100644--- a/src/lib/cli-helper/config-generator/continue.ts+++ b/src/lib/cli-helper/config-generator/continue.ts@@ -17,7 +17,9 @@ export async function generateContinueConfig(options: {model?: string;}): Promise<string> {const y = await loadYaml();- const base = options.baseUrl.replace(/\/+$/, "").replace(/\/v1$/, "");+ let base = options.baseUrl;+ while (base.endsWith("/")) base = base.slice(0, -1);+ if (base.endsWith("/v1")) base = base.slice(0, -3);const config = {models: [diff --git a/src/lib/cli-helper/config-generator/kilocode.ts b/src/lib/cli-helper/config-generator/kilocode.tsindex 8c43dcd407..87596d88d4 100644--- a/src/lib/cli-helper/config-generator/kilocode.ts+++ b/src/lib/cli-helper/config-generator/kilocode.ts@@ -8,7 +8,9 @@ export function generateKilocodeConfig(options: {apiKey: string;model?: string;}): string {- const base = options.baseUrl.replace(/\/+$/, "").replace(/\/v1$/, "");+ let base = options.baseUrl;+ while (base.endsWith("/")) base = base.slice(0, -1);+ if (base.endsWith("/v1")) base = base.slice(0, -3);const config = {apiKey: options.apiKey,diff --git a/src/lib/cli-helper/config-generator/opencode.ts b/src/lib/cli-helper/config-generator/opencode.tsindex b17214dac7..0d4667a90b 100644--- a/src/lib/cli-helper/config-generator/opencode.ts+++ b/src/lib/cli-helper/config-generator/opencode.ts@@ -8,7 +8,9 @@ export function generateOpencodeConfig(options: {apiKey: string;model?: string;}): string {- const base = options.baseUrl.replace(/\/+$/, "").replace(/\/v1$/, "");+ let base = options.baseUrl;+ while (base.endsWith("/")) base = base.slice(0, -1);+ if (base.endsWith("/v1")) base = base.slice(0, -3);const config = {provider: "omniroute",diff --git a/tests/live/deepseek-web-live.test.ts b/tests/live/deepseek-web-live.test.tsindex d117a8c04c..e0f42214fa 100644--- a/tests/live/deepseek-web-live.test.ts+++ b/tests/live/deepseek-web-live.test.ts@@ -25,7 +25,11 @@ if (!process.env.DEEPSEEK_WEB_SESSION_COOKIE) {});assert.ok(result.response, "Should return a response");- assert.ok(result.url.includes("chat.deepseek.com"), "Should target chat.deepseek.com");+ assert.equal(+ new URL(result.url).hostname,+ "chat.deepseek.com",+ "Should target chat.deepseek.com"+ );if (result.response.ok) {const ct = result.response.headers.get("content-type") || "";