splitQueryParameterByDelimiter takes a query string and splits it into the individual elements of the query. Each element is separated by a delimiter. All quoted strings are kept as a single element. Although all our names cannot have spaces, that is a validation error. We should still parse the qu
(query string, delimiter rune, maintainQuotes bool)
| 813 | // an error. |
| 814 | // nolint:revive |
| 815 | func splitQueryParameterByDelimiter(query string, delimiter rune, maintainQuotes bool) []string { |
| 816 | quoted := false |
| 817 | parts := strings.FieldsFunc(query, func(r rune) bool { |
| 818 | if r == '"' { |
| 819 | quoted = !quoted |
| 820 | } |
| 821 | return !quoted && r == delimiter |
| 822 | }) |
| 823 | if !maintainQuotes { |
| 824 | for i, part := range parts { |
| 825 | parts[i] = strings.Trim(part, "\"") |
| 826 | } |
| 827 | } |
| 828 | |
| 829 | return parts |
| 830 | } |
| 831 | |
| 832 | // processTokens takes the split tokens and groups them based on a delimiter (':'). |
| 833 | // Tokens without a delimiter present are joined to support searching with spaces. |
no outgoing calls
no test coverage detected