Skip to content

Commit f2864b0

Browse files
committed
Fixed SearchTermsFromQueryString function
1 parent a4553fd commit f2864b0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: rpc/cc/arduino/cli/commands/v1/search.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@
1515

1616
package commands
1717

18-
import "strings"
18+
import (
19+
"strings"
20+
"unicode"
21+
)
1922

2023
// SearchTermsFromQueryString returns the terms inside the query string.
2124
// All non alphanumeric characters (expect ':') are considered separators.
2225
// All search terms are converted to lowercase.
2326
func SearchTermsFromQueryString(query string) []string {
2427
// Split on anything but 0-9, a-z or :
2528
return strings.FieldsFunc(strings.ToLower(query), func(r rune) bool {
26-
return !((r >= '0' && r <= '9') || (r >= 'a' && r <= 'z') || r == ':')
29+
return !unicode.IsLetter(r) && !unicode.IsNumber(r) && r != ':'
2730
})
2831
}

0 commit comments

Comments
 (0)