parseStringSliceSep returns a parser that splits by a custom separator. The separator is obtained from the provided StringVar descriptor.
(separatorDesc StringVar)
| 82 | // parseStringSliceSep returns a parser that splits by a custom separator. |
| 83 | // The separator is obtained from the provided StringVar descriptor. |
| 84 | func 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. |
no test coverage detected