Skip to content

Commit cc5a8ab

Browse files
mparryMatthew Fisher
authored andcommitted
fix(helm): Don't crash in search if upper case chars are encountered.
Closes #3088 (cherry picked from commit d848990)
1 parent ae8ddf3 commit cc5a8ab

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

cmd/helm/search/search.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@ func (i *Index) SearchLiteral(term string, threshold int) []*Result {
146146
term = strings.ToLower(term)
147147
buf := []*Result{}
148148
for k, v := range i.lines {
149-
k = strings.ToLower(k)
150-
v = strings.ToLower(v)
151-
res := strings.Index(v, term)
152-
if score := i.calcScore(res, v); res != -1 && score < threshold {
153-
parts := strings.Split(k, verSep) // Remove version, if it is there.
149+
lk := strings.ToLower(k)
150+
lv := strings.ToLower(v)
151+
res := strings.Index(lv, term)
152+
if score := i.calcScore(res, lv); res != -1 && score < threshold {
153+
parts := strings.Split(lk, verSep) // Remove version, if it is there.
154154
buf = append(buf, &Result{Name: parts[0], Score: score, Chart: i.charts[k]})
155155
}
156156
}

cmd/helm/search/search_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ var indexfileEntries = map[string]repo.ChartVersions{
9191
},
9292
},
9393
{
94-
URLs: []string{"http://example.com/charts/santa-maria-1.2.2.tgz"},
94+
URLs: []string{"http://example.com/charts/santa-maria-1.2.2-rc-1.tgz"},
9595
Metadata: &chart.Metadata{
9696
Name: "santa-maria",
97-
Version: "1.2.2",
97+
Version: "1.2.2-RC-1",
9898
Description: "Three boat",
9999
},
100100
},

0 commit comments

Comments
 (0)