fix: new URL should always be in a try block

This commit is contained in:
Simon
2026-07-03 20:14:11 +08:00
parent 5aeb67f6d6
commit 10276c6e67
+4
View File
@@ -209,8 +209,12 @@ export function normalizeModelName(modelName: string): string {
export function getProvider(baseURL?: string): 'openrouter' | undefined {
if (!baseURL) return undefined
try {
const url = new URL(baseURL)
const hostname = url.hostname
if (hostname === 'openrouter.ai') return 'openrouter'
return undefined
} catch (e) {
return undefined
}
}