Skip to content

Commit

Permalink
fix(search): only do exact trim in certain modes (#2045)
Browse files Browse the repository at this point in the history
only do exact trim in certain modes
  • Loading branch information
Jguer authored Apr 2, 2023
1 parent d13bdb0 commit dd42593
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/query/query_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,24 @@ func (s *SourceQueryBuilder) Execute(ctx context.Context, dbExecutor db.Executor
aurResults, aurErr = queryAUR(ctx, s.aurClient, pkgS, s.searchBy)
dbName := sourceAUR

isRegex := false
// Check if the search is a regex by checking if pkgS it contains a special character
for _, c := range pkgS[0] {
if !unicode.IsLetter(c) && !unicode.IsNumber(c) {
isRegex = true
break
}
}

for i := range aurResults {
if s.queryMap[dbName] == nil {
s.queryMap[dbName] = map[string]interface{}{}
}

if !matchesSearch(&aurResults[i], pkgS) {
by := getSearchBy(s.searchBy)

if (by == aur.NameDesc || by == aur.None || by == aur.Name) && !isRegex &&
!matchesSearch(&aurResults[i], pkgS) {
continue
}

Expand Down

0 comments on commit dd42593

Please sign in to comment.