fix: validate usage profile query type

This commit is contained in:
Kai (Tam Nhu) Tran authored and Tam Nhu Tran committed 2026-05-30 15:20:15 -04:00
1 parent 62a4d44b58
commit 901bad2ec7
2 files changed
+25 -8

No files matched your search

+7 -2
View File
@@ -9,8 +9,13 @@ export interface ProfileScopedUsageData {
const PROFILE_NAME_REGEX = /^[A-Za-z0-9._-]+$/;
export function normalizeProfileQuery(profile?: string): string | undefined {
const value = profile?.trim();
export function normalizeProfileQuery(profile?: unknown): string | undefined {
if (profile === undefined) return undefined;
if (typeof profile !== 'string') {
throw new Error('Invalid profile filter');
}
const value = profile.trim();
if (!value || value === 'all') return undefined;
if (!PROFILE_NAME_REGEX.test(value)) {
throw new Error('Invalid profile filter');