From d8489901224c8279b724c84c0f17df67a9d5aaf2 Mon Sep 17 00:00:00 2001 From: Morgan Parry Date: Tue, 6 Mar 2018 11:06:50 +0000 Subject: [PATCH] fix(helm): Don't crash in search if upper case chars are encountered. Closes #3088 --- cmd/helm/search/search.go | 10 +++++----- cmd/helm/search/search_test.go | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/helm/search/search.go b/cmd/helm/search/search.go index a24208a4b..6c4cb4aa4 100644 --- a/cmd/helm/search/search.go +++ b/cmd/helm/search/search.go @@ -146,11 +146,11 @@ func (i *Index) SearchLiteral(term string, threshold int) []*Result { term = strings.ToLower(term) buf := []*Result{} for k, v := range i.lines { - k = strings.ToLower(k) - v = strings.ToLower(v) - res := strings.Index(v, term) - if score := i.calcScore(res, v); res != -1 && score < threshold { - parts := strings.Split(k, verSep) // Remove version, if it is there. + lk := strings.ToLower(k) + lv := strings.ToLower(v) + res := strings.Index(lv, term) + if score := i.calcScore(res, lv); res != -1 && score < threshold { + parts := strings.Split(lk, verSep) // Remove version, if it is there. buf = append(buf, &Result{Name: parts[0], Score: score, Chart: i.charts[k]}) } } diff --git a/cmd/helm/search/search_test.go b/cmd/helm/search/search_test.go index 949cf7be7..574f55448 100644 --- a/cmd/helm/search/search_test.go +++ b/cmd/helm/search/search_test.go @@ -91,10 +91,10 @@ var indexfileEntries = map[string]repo.ChartVersions{ }, }, { - URLs: []string{"http://example.com/charts/santa-maria-1.2.2.tgz"}, + URLs: []string{"http://example.com/charts/santa-maria-1.2.2-rc-1.tgz"}, Metadata: &chart.Metadata{ Name: "santa-maria", - Version: "1.2.2", + Version: "1.2.2-RC-1", Description: "Three boat", }, },