From 2a7a55eca4b5abc90a9f3edb37b5548fdbeb229c Mon Sep 17 00:00:00 2001 From: boombuler Date: Wed, 28 Sep 2016 17:55:44 +0200 Subject: [PATCH] better plugin search --- cmd/micro/pluginmanager.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/cmd/micro/pluginmanager.go b/cmd/micro/pluginmanager.go index 969c29c7..27cd802e 100644 --- a/cmd/micro/pluginmanager.go +++ b/cmd/micro/pluginmanager.go @@ -9,7 +9,6 @@ import ( "net/http" "os" "path/filepath" - "regexp" "sort" "strings" "sync" @@ -240,11 +239,20 @@ func (s PluginVersions) Less(i, j int) bool { // Match returns true if the package matches a given search text func (pp PluginPackage) Match(text string) bool { - // ToDo: improve matching. - text = "(?i)" + text - if r, err := regexp.Compile(text); err == nil { - return r.MatchString(pp.Name) + text = strings.ToLower(text) + for _, t := range pp.Tags { + if strings.ToLower(t) == text { + return true + } } + if strings.Contains(strings.ToLower(pp.Name), text) { + return true + } + + if strings.Contains(strings.ToLower(pp.Description), text) { + return true + } + return false }