fix: address code review findings

This commit is contained in:
2026-07-19 20:53:06 +03:00
parent da8b8aa944
commit 2468859435
9 changed files with 34 additions and 228 deletions

View File

@@ -16,13 +16,13 @@ import (
var (
bracketRe = regexp.MustCompile(`\[[^\]]*\]`)
parenRe = regexp.MustCompile(`\([^)]*\)`)
yearRe = regexp.MustCompile(`\b(1[0-9]{3}|2[0-9]{3})\b`)
yearRe = regexp.MustCompile(`\b[0-9]{4}\b`)
spaceRe = regexp.MustCompile(`\s+`)
// bareYearRe matches a title that is *only* a single year (with optional
// surrounding whitespace), e.g. "1989" or "2112". Used to decide whether a
// title that collapses entirely to a year should keep it (so it matches
// itself) or be treated as a distinct reissue that must collapse to empty.
bareYearRe = regexp.MustCompile(`^\s*(1[0-9]{3}|2[0-9]{3})\s*$`)
bareYearRe = regexp.MustCompile(`^\s*[0-9]{4}\s*$`)
)
// NormalizeString normalizes a string for fuzzy matching by:
@@ -46,7 +46,7 @@ func NormalizeString(s string) string {
// Remove parenthesized content (e.g., (Deluxe), (Remastered))
s = parenRe.ReplaceAllString(s, "")
// Remove years (4-digit numbers between 1000-2999). If stripping the year
// Remove years (any 4-digit number). If stripping the year
// empties the entire string, decide what to keep:
// - A bare year title (e.g. "1989", "2112") has no other words, so keep
// the year so it can still match itself (the user owns that album).