Chore: Allow @ character in message tags & set max length to 100 characters per tag

This commit is contained in:
Ralph Slooten
2026-01-17 11:12:45 +13:00
parent 45b3676e52
commit 7cda4a36f1
4 changed files with 14 additions and 7 deletions

View File

@@ -10,7 +10,7 @@ import (
var (
// Invalid tag characters regex
tagsInvalidChars = regexp.MustCompile(`[^a-zA-Z0-9\-\ \_\.]`)
tagsInvalidChars = regexp.MustCompile(`[^a-zA-Z0-9\-\ \_\.@]`)
// Regex to catch multiple spaces
multiSpaceRe = regexp.MustCompile(`(\s+)`)
@@ -19,14 +19,21 @@ var (
TagsTitleCase bool
)
// CleanTag returns a clean tag, trimming whitespace and replacing invalid characters
// CleanTag returns a clean tag, trimming whitespace and replacing invalid characters.
// If the tag is longer than 100 characters, it is truncated.
func CleanTag(s string) string {
return strings.TrimSpace(
t := strings.TrimSpace(
multiSpaceRe.ReplaceAllString(
tagsInvalidChars.ReplaceAllString(s, " "),
" ",
),
)
if len(t) > 100 {
return t[:100]
}
return t
}
// SetTagCasing returns the slice of tags, title-casing if set