Skip to content

Commit

Permalink
fix(helm): Don't crash in search if upper case chars are encountered.
Browse files Browse the repository at this point in the history
Closes #3088

(cherry picked from commit d848990)
  • Loading branch information
mparry authored and Matthew Fisher committed Mar 9, 2018
1 parent ae8ddf3 commit cc5a8ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions cmd/helm/search/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]})
}
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/helm/search/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
Expand Down

0 comments on commit cc5a8ab

Please sign in to comment.