This commit is contained in:
2026-05-23 17:17:56 -07:00
commit 448f2e33ef
135 changed files with 11817 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
export const validTagMatcher = new RegExp(/^[\p{L}\p{N}_]+$/u)
// Format user input for api requests, returns an empty string if invalid
export function formatTagInput(str: string): string | false {
const normal = str.trim().toLowerCase().replaceAll(/\s\s+/g, ' ').replaceAll(' ', '_')
if (!validTagMatcher.test(normal)) {
return false
}
return normal
}
// Format tag label for display in html
export function formatTagTextContent(str: string): string {
return str.trim().toUpperCase().replace('_', ' ')
}
// Format tag usage for display in html
export function formatTagUsage(num: number): string {
return num.toLocaleString()
}