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

Function parseStringSliceSep

env/parsers.go:84–97  ·  view source on GitHub ↗

parseStringSliceSep returns a parser that splits by a custom separator. The separator is obtained from the provided StringVar descriptor.

(separatorDesc StringVar)

Source from the content-addressed store, hash-verified

82// parseStringSliceSep returns a parser that splits by a custom separator.
83// The separator is obtained from the provided StringVar descriptor.
84func parseStringSliceSep(separatorDesc StringVar) ParseFn[[]string] {
85 return func(env string) ([]string, error) {
86 sep, ok := separatorDesc.GetEnv()
87 if !ok || sep == "" {
88 sep = "," // default to comma if separator not provided
89 }
90 parts := strings.Split(env, sep)
91 result := make([]string, len(parts))
92 for i, p := range parts {
93 result[i] = strings.TrimSpace(p)
94 }
95 return result, nil
96 }
97}
98
99// parseURLPath normalizes a URL path by removing query strings and fragments,
100// ensuring it has a leading slash and no trailing slash.

Callers 1

StringSliceSepFunction · 0.85

Calls 2

GetEnvMethod · 0.80
SplitMethod · 0.80

Tested by

no test coverage detected