(url: string)
| 256 | } |
| 257 | |
| 258 | function sanitizeOpenAICompatibleBaseUrl(url: string): string { |
| 259 | const trimmed = trimApiUrl(url); |
| 260 | |
| 261 | try { |
| 262 | const parsed = new URL(trimmed); |
| 263 | const segments = parsed.pathname.split("/").filter(Boolean); |
| 264 | |
| 265 | while (segments.length > 0) { |
| 266 | const lastSegment = segments[segments.length - 1]?.toLowerCase(); |
| 267 | if (!lastSegment || !CONSOLE_PATH_SEGMENTS.has(lastSegment)) { |
| 268 | break; |
| 269 | } |
| 270 | segments.pop(); |
| 271 | } |
| 272 | |
| 273 | parsed.pathname = segments.length > 0 ? `/${segments.join("/")}` : "/"; |
| 274 | parsed.search = ""; |
| 275 | parsed.hash = ""; |
| 276 | |
| 277 | return trimApiUrl(parsed.toString()); |
| 278 | } catch { |
| 279 | return trimmed; |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | export function providerSupportsExactRequestUrl(providerId: string): boolean { |
| 284 | return providerId !== "anthropic" && providerId !== "google"; |
no test coverage detected