limit tag length
This commit is contained in:
parent
9d8eb32f9f
commit
e496ad670a
1 changed files with 6 additions and 1 deletions
|
@ -71,6 +71,8 @@ func SanitizeTags(tags []string, youtubeChannelID string) ([]string, error) {
|
||||||
return sanitizedTags, nil
|
return sanitizedTags, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const TagMaxLength = 255
|
||||||
|
|
||||||
func normalizeTag(t string) (string, error) {
|
func normalizeTag(t string) (string, error) {
|
||||||
t = strings.ToLower(t)
|
t = strings.ToLower(t)
|
||||||
multipleSpaces := regexp.MustCompile(`\s{2,}`)
|
multipleSpaces := regexp.MustCompile(`\s{2,}`)
|
||||||
|
@ -87,7 +89,10 @@ func normalizeTag(t string) (string, error) {
|
||||||
if weirdChars.MatchString(t) {
|
if weirdChars.MatchString(t) {
|
||||||
log.Debugf("tag '%s' has weird stuff in it, skipping\n", t)
|
log.Debugf("tag '%s' has weird stuff in it, skipping\n", t)
|
||||||
return "", nil
|
return "", nil
|
||||||
|
}
|
||||||
|
if len(t) > TagMaxLength {
|
||||||
|
log.Debugf("tag '%s' is too long, skipping\n", t)
|
||||||
|
return "", nil
|
||||||
}
|
}
|
||||||
return t, nil
|
return t, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue