(fullUrl: string)
| 73 | * @returns The base URL (scheme + host) |
| 74 | */ |
| 75 | export function extractBaseUrl(fullUrl: string): string { |
| 76 | try { |
| 77 | const url = new URL(fullUrl) |
| 78 | return `${url.protocol}//${url.host}` |
| 79 | } catch { |
| 80 | // If parsing fails, try to extract up to .com or .azure.com |
| 81 | const match = fullUrl.match(/^(https?:\/\/[^/]+)/) |
| 82 | return match ? match[1] : fullUrl |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Extracts the deployment name from a full Azure OpenAI URL. |