MCPcopy Index your code
hub / github.com/coder/coder / splitQueryParameterByDelimiter

Function splitQueryParameterByDelimiter

coderd/searchquery/search.go:815–830  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

813// an error.
814// nolint:revive
815func 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.

Callers 2

WorkspacesFunction · 0.85
searchTermsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected