MCPcopy Index your code
hub / github.com/docker/docker-agent / keyNormalizer

Function keyNormalizer

pkg/cache/cache.go:247–257  ·  view source on GitHub ↗

keyNormalizer returns a function that applies the configured normalization rules to a question before it is used as a cache key. Trim runs before lowercase: trim only removes leading/trailing whitespace and is unaffected by case, so the order is irrelevant for correctness, but trim-first keeps the l

(caseSensitive, trimSpaces bool)

Source from the content-addressed store, hash-verified

245// correctness, but trim-first keeps the lowercased map keys tighter on
246// inputs like " HELLO\n".
247func keyNormalizer(caseSensitive, trimSpaces bool) func(string) string {
248 return func(s string) string {
249 if trimSpaces {
250 s = strings.TrimSpace(s)
251 }
252 if !caseSensitive {
253 s = strings.ToLower(s)
254 }
255 return s
256 }
257}
258
259// loadFromFile decodes path into entries. A missing file is not an error
260// and leaves entries empty.

Callers 1

NewFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected