diff options
Diffstat (limited to 'src/lib/util.ts')
| -rw-r--r-- | src/lib/util.ts | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/lib/util.ts b/src/lib/util.ts index 9903e2c..b8be8cb 100644 --- a/src/lib/util.ts +++ b/src/lib/util.ts @@ -1,3 +1,18 @@ -export function stripColourCodes(str: string): string { - return str.replace(/&[0-9a-fk-or]/i, ''); +const COLOR_CODE_REGEX = /&[0-9a-fk-or]/i; +const VALID_ID_REGEX = /^[a-z0-9_]+$/i; + +export function stripColorCodes(str: string): string { + return str.replace(COLOR_CODE_REGEX, ''); +} + +export function validateQuestId(id: string): boolean { + return VALID_ID_REGEX.test(id); +} + +export function validateCategoryId(id: string): boolean { + return VALID_ID_REGEX.test(id); +} + +export function validateTaskId(id: string): boolean { + return VALID_ID_REGEX.test(id); }
\ No newline at end of file |
