diff --git a/src/router/apiKeyManager.ts b/src/router/apiKeyManager.ts index 12e5d23..e906490 100644 --- a/src/router/apiKeyManager.ts +++ b/src/router/apiKeyManager.ts @@ -10,10 +10,10 @@ export class ApiKeyManager { * Register an API key for a provider */ public registerKey(provider: string, apiKey: string): void { - if (!provider || typeof provider !== 'string' || provider.trim() === '') { + if (!provider || typeof provider !== 'string' || provider.trim().length === 0) { throw new Error('TokenFirewall: Provider must be a non-empty string'); } - if (!apiKey || typeof apiKey !== 'string' || apiKey.trim() === '') { + if (!apiKey || typeof apiKey !== 'string' || apiKey.trim().length === 0) { throw new Error(`TokenFirewall: Invalid API key for provider "${provider}"`); } this.keys.set(provider.toLowerCase(), apiKey); diff --git a/src/router/modelRouter.ts b/src/router/modelRouter.ts index 4b6f8ea..de6a573 100644 --- a/src/router/modelRouter.ts +++ b/src/router/modelRouter.ts @@ -64,7 +64,7 @@ export class ModelRouter { // Validate each fallback model name for (const fallbackModel of fallbacks) { - if (typeof fallbackModel !== 'string' || fallbackModel.trim() === '') { + if (typeof fallbackModel !== 'string' || fallbackModel.trim().length === 0) { throw new Error( `TokenFirewall Router: fallbackMap for "${model}" contains invalid model name (empty or whitespace)` );