MCPcopy Create free account
hub / github.com/NV404/gova / normalizeExtensions

Function normalizeExtensions

dialog.go:282–305  ·  view source on GitHub ↗

normalizeExtensions trims and lowercases each extension and ensures it starts with a dot.

(in []string)

Source from the content-addressed store, hash-verified

280// normalizeExtensions trims and lowercases each extension and ensures it
281// starts with a dot.
282func normalizeExtensions(in []string) []string {
283 if len(in) == 0 {
284 return nil
285 }
286 out := make([]string, 0, len(in))
287 for _, s := range in {
288 if s == "" {
289 continue
290 }
291 // strings.ToLower without importing strings: manual cast.
292 b := []byte(s)
293 for i, c := range b {
294 if c >= 'A' && c <= 'Z' {
295 b[i] = c + 32
296 }
297 }
298 s = string(b)
299 if s[0] != '.' {
300 s = "." + s
301 }
302 out = append(out, s)
303 }
304 return out
305}

Callers 3

TypesMethod · 0.85
TypesMethod · 0.85
TestNormalizeExtensionsFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestNormalizeExtensionsFunction · 0.68