fix: address code review findings

This commit is contained in:
2026-07-19 18:59:38 +03:00
parent 8a5b58a817
commit a4c426f640
3 changed files with 33 additions and 6 deletions

View File

@@ -37,8 +37,13 @@ func NormalizeString(s string) string {
// Remove parenthesized content (e.g., (Deluxe), (Remastered))
s = parenRe.ReplaceAllString(s, "")
// Remove years (4-digit numbers between 1000-2999)
s = yearRe.ReplaceAllString(s, "")
// Remove years (4-digit numbers between 1000-2999). If stripping the
// year would empty the entire string (e.g. an album literally titled
// "1989" or "2112"), keep the original form so the title can still match.
stripped := yearRe.ReplaceAllString(s, "")
if strings.TrimSpace(stripped) != "" {
s = stripped
}
// Replace common separators with spaces before stripping other special chars
s = strings.ReplaceAll(s, "-", " ")