fix: new URL should always be in a try block
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user