@@ -127,24 +127,24 @@ func matcherFromQueryString(query string) func(*librariesindex.Library) bool {
127
127
matched := true
128
128
for _ , term := range queryTerms {
129
129
130
- // Flag indicating whether the search term matched a known qualifier
131
- knownQualifier := false
132
-
133
- for key , extractor := range qualifiers {
134
- if strings .HasPrefix (term , key + ":" ) {
135
- target := strings .TrimPrefix (term , key + ":" )
136
- matched = (matched && utils .Match (extractor (lib ), []string {target }))
137
- knownQualifier = true
138
- break
139
- } else if strings .HasPrefix (term , key + "=" ) {
140
- target := strings .TrimPrefix (term , key + "=" )
141
- matched = (matched && strings .ToLower (extractor (lib )) == target )
142
- knownQualifier = true
143
- break
130
+ if sepIdx := strings .IndexAny (term , "=:" ); sepIdx != - 1 {
131
+ potentialKey := term [:sepIdx ]
132
+ separator := term [sepIdx ]
133
+
134
+ extractor , ok := qualifiers [potentialKey ]
135
+ if ok {
136
+ target := term [sepIdx + 1 :]
137
+ if separator == ':' {
138
+ matched = (matched && utils .Match (extractor (lib ), []string {target }))
139
+ } else { // "="
140
+ matched = (matched && strings .ToLower (extractor (lib )) == target )
141
+ }
142
+ } else {
143
+ // Unknown qualifier names revert to basic search terms.
144
+ matched = (matched && utils .Match (defaultLibraryMatchExtractor (lib ), []string {term }))
144
145
}
145
- }
146
-
147
- if ! knownQualifier {
146
+ } else {
147
+ // Terms that do not use qv-syntax are handled as usual.
148
148
matched = (matched && utils .Match (defaultLibraryMatchExtractor (lib ), []string {term }))
149
149
}
150
150
}
0 commit comments