mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-10 02:17:11 +00:00
Merge pull request #1433 from kaitranntt/codex/fix-issue-with-profile-query-handling
fix: validate usage profile query type
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user