Files
calculate_negative_points/internal/utils/normalize_name.go
Eugene Howe b0957bfa49
Some checks failed
Docker Build and Publish / publish (push) Failing after 1m33s
webapp
2026-02-17 09:47:30 -05:00

24 lines
442 B
Go

package utils
import (
"regexp"
"strings"
"unicode"
)
func NormalizeName(name string) string {
// Remove extra whitespace
name = strings.TrimSpace(name)
name = regexp.MustCompile(`\s+`).ReplaceAllString(name, " ")
// Remove common punctuation but keep hyphens
name = strings.Map(func(r rune) rune {
if unicode.IsLetter(r) || unicode.IsSpace(r) || r == '-' {
return unicode.ToLower(r)
}
return -1
}, name)
return name
}