mirror of
https://github.com/Jguer/yay.git
synced 2025-12-13 00:04:02 -05:00
fix(search): always trust search if there's only one term (#2046)
always trust search if there's only one term
This commit is contained in:
parent
dd42593ba1
commit
c63576c36d
@ -129,23 +129,13 @@ func (s *SourceQueryBuilder) Execute(ctx context.Context, dbExecutor db.Executor
|
|||||||
aurResults, aurErr = queryAUR(ctx, s.aurClient, pkgS, s.searchBy)
|
aurResults, aurErr = queryAUR(ctx, s.aurClient, pkgS, s.searchBy)
|
||||||
dbName := sourceAUR
|
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 {
|
for i := range aurResults {
|
||||||
if s.queryMap[dbName] == nil {
|
if s.queryMap[dbName] == nil {
|
||||||
s.queryMap[dbName] = map[string]interface{}{}
|
s.queryMap[dbName] = map[string]interface{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
by := getSearchBy(s.searchBy)
|
by := getSearchBy(s.searchBy)
|
||||||
|
if (by == aur.NameDesc || by == aur.None || by == aur.Name) &&
|
||||||
if (by == aur.NameDesc || by == aur.None || by == aur.Name) && !isRegex &&
|
|
||||||
!matchesSearch(&aurResults[i], pkgS) {
|
!matchesSearch(&aurResults[i], pkgS) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -263,10 +253,15 @@ func (s *SourceQueryBuilder) GetTargets(include, exclude intrange.IntRanges,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func matchesSearch(pkg *aur.Pkg, terms []string) bool {
|
func matchesSearch(pkg *aur.Pkg, terms []string) bool {
|
||||||
|
if len(terms) <= 1 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
for _, pkgN := range terms {
|
for _, pkgN := range terms {
|
||||||
if strings.IndexFunc(pkgN, unicode.IsSymbol) != -1 {
|
if strings.IndexFunc(pkgN, unicode.IsSymbol) != -1 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
name := strings.ToLower(pkg.Name)
|
name := strings.ToLower(pkg.Name)
|
||||||
desc := strings.ToLower(pkg.Description)
|
desc := strings.ToLower(pkg.Description)
|
||||||
targ := strings.ToLower(pkgN)
|
targ := strings.ToLower(pkgN)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user