diff options
Diffstat (limited to 'lib/util.ts')
| -rw-r--r-- | lib/util.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/util.ts b/lib/util.ts new file mode 100644 index 0000000..b8be8cb --- /dev/null +++ b/lib/util.ts @@ -0,0 +1,18 @@ +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 |
