File tree 2 files changed +13
-17
lines changed
2 files changed +13
-17
lines changed Original file line number Diff line number Diff line change @@ -47,20 +47,20 @@ func removeDiatrics(s string) (string, error) {
47
47
// Both str and substrings are transforms to lower case and have their
48
48
// accents and other unicode diatrics removed.
49
49
// If strings transformation fails an error is returned.
50
- func Match (str string , substrings []string ) (bool , error ) {
51
- str , err := removeDiatrics (strings .ToLower (str ))
52
- if err != nil {
53
- return false , err
50
+ func Match (str string , substrings []string ) bool {
51
+ clean := func (s string ) string {
52
+ s = strings .ToLower (s )
53
+ if s2 , err := removeDiatrics (s ); err == nil {
54
+ return s2
55
+ }
56
+ return s
54
57
}
55
58
59
+ str = clean (str )
56
60
for _ , sub := range substrings {
57
- cleanSub , err := removeDiatrics (strings .ToLower (sub ))
58
- if err != nil {
59
- return false , err
60
- }
61
- if ! strings .Contains (str , cleanSub ) {
62
- return false , nil
61
+ if ! strings .Contains (str , clean (sub )) {
62
+ return false
63
63
}
64
64
}
65
- return true , nil
65
+ return true
66
66
}
Original file line number Diff line number Diff line change @@ -54,12 +54,8 @@ func PlatformSearch(req *rpc.PlatformSearchRequest) (*rpc.PlatformSearchResponse
54
54
}
55
55
56
56
for _ , t := range toTest {
57
- matches , err := utils .Match (t , searchArgs )
58
- if err != nil {
59
- return false , err
60
- }
61
- if matches {
62
- return matches , nil
57
+ if utils .Match (t , searchArgs ) {
58
+ return true , nil
63
59
}
64
60
}
65
61
return false , nil
You can’t perform that action at this time.
0 commit comments