MCPcopy Create free account
hub / github.com/arctic-cli/interface / normalizeCodexBaseUrl

Function normalizeCodexBaseUrl

packages/arctic/src/provider/codex-backend.ts:36–49  ·  view source on GitHub ↗
(input?: string | null)

Source from the content-addressed store, hash-verified

34 * - Ensures chatgpt.com/.openai.com hosts include /backend-api for WHAM endpoints.
35 */
36export function normalizeCodexBaseUrl(input?: string | null): string {
37 let normalized =
38 typeof input === "string" && input.trim().length > 0 ? input.trim() : CODEX_BASE_URL
39 while (normalized.endsWith("/")) {
40 normalized = normalized.slice(0, -1)
41 }
42 if (
43 (normalized.startsWith("https://chatgpt.com") || normalized.startsWith("https://chat.openai.com")) &&
44 !normalized.includes("/backend-api")
45 ) {
46 normalized = `${normalized}/backend-api`
47 }
48 return normalized
49}
50
51/**
52 * Builds the fully qualified URL for the usage endpoint, matching the Codex CLI logic:

Callers 2

buildCodexUsageUrlFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected