Normalize maps a name to its canonical form using the taxonomy. Returns the lowercase name if no taxonomy match is found.
(name string, taxonomy *config.Taxonomy)
| 19 | // Normalize maps a name to its canonical form using the taxonomy. |
| 20 | // Returns the lowercase name if no taxonomy match is found. |
| 21 | func Normalize(name string, taxonomy *config.Taxonomy) string { |
| 22 | n := strings.ToLower(strings.TrimSpace(name)) |
| 23 | if n == "" { |
| 24 | return "" |
| 25 | } |
| 26 | if taxonomy == nil { |
| 27 | return n |
| 28 | } |
| 29 | if canonical, ok := taxonomy.Lookup(n); ok { |
| 30 | return canonical |
| 31 | } |
| 32 | return n |
| 33 | } |