From dd42593ba1d06509d4dd29a6138e4a36b3fdf896 Mon Sep 17 00:00:00 2001 From: Jo Date: Sun, 2 Apr 2023 18:50:35 +0100 Subject: [PATCH] fix(search): only do exact trim in certain modes (#2045) only do exact trim in certain modes --- pkg/query/query_builder.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/query/query_builder.go b/pkg/query/query_builder.go index 880ff5efa..8d1f17034 100644 --- a/pkg/query/query_builder.go +++ b/pkg/query/query_builder.go @@ -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 }