(input?: string | null)
| 34 | * - Ensures chatgpt.com/.openai.com hosts include /backend-api for WHAM endpoints. |
| 35 | */ |
| 36 | export 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: |
no outgoing calls
no test coverage detected