MCPcopy
hub / github.com/six2dez/OneListForAll / Normalize

Function Normalize

internal/categories/normalize.go:21–33  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

19// Normalize maps a name to its canonical form using the taxonomy.
20// Returns the lowercase name if no taxonomy match is found.
21func 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}

Callers 2

TestNormalizeNilTaxonomyFunction · 0.85

Calls 1

LookupMethod · 0.80

Tested by 2

TestNormalizeNilTaxonomyFunction · 0.68