MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / parseStringMap

Function parseStringMap

env/parsers.go:212–230  ·  view source on GitHub ↗

parseStringMap parses semicolon-separated key=value pairs and returns a map. Empty entries are skipped.

(env string)

Source from the content-addressed store, hash-verified

210// parseStringMap parses semicolon-separated key=value pairs and returns a map.
211// Empty entries are skipped.
212func parseStringMap(env string) (map[string]string, error) {
213 result := make(map[string]string)
214 keyvalues := strings.SplitSeq(env, ";")
215
216 for kv := range keyvalues {
217 kv = strings.TrimSpace(kv)
218 if len(kv) == 0 {
219 continue
220 }
221
222 parts := strings.SplitN(kv, "=", 2)
223 if len(parts) != 2 {
224 return nil, fmt.Errorf("invalid key/value: %s", kv)
225 }
226 result[parts[0]] = parts[1]
227 }
228
229 return result, nil
230}
231
232// RegexpFromPattern creates a regexp from a wildcard pattern.
233// Converts shell-style wildcards to regexp patterns.

Callers

nothing calls this directly

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected