Skip to content
This repository was archived by the owner on Jul 16, 2021. It is now read-only.

Commit cb64e9f

Browse files
scottrigbyprydonius
authored andcommitted
Check member is defined before calling match (#616)
* Check member is defined before calling match Signed-off-by: Scott Rigby <scott@r6by.com> * Pass string not bang bang bool Signed-off-by: Scott Rigby <scott@r6by.com>
1 parent 8370687 commit cb64e9f

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

frontend/src/app/shared/services/charts.service.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,25 @@ export class ChartsService {
7272
let re = new RegExp(query, 'i');
7373
return this.getCharts(repo).map(charts => {
7474
return charts.filter(chart => {
75-
return chart.attributes.name.match(re) ||
76-
chart.attributes.description.match(re) ||
77-
chart.attributes.repo.name.match(re) ||
75+
return this.checkDefinedMatch(chart.attributes.name, re) ||
76+
this.checkDefinedMatch(chart.attributes.description, re) ||
77+
this.checkDefinedMatch(chart.attributes.repo.name, re) ||
7878
this.arrayMatch(chart.attributes.keywords, re) ||
7979
this.arrayMatch((chart.attributes.maintainers || []).map((m)=> { return m.name }), re) ||
8080
this.arrayMatch(chart.attributes.sources, re)
8181
})
8282
})
8383
}
8484

85+
checkDefinedMatch(member, matcher) {
86+
return member && member.match(matcher);
87+
}
88+
8589
arrayMatch(keywords: string[], re): boolean {
8690
if(!keywords) return false
8791

8892
return keywords.some((keyword) => {
89-
return !!keyword.match(re)
93+
return this.checkDefinedMatch(keyword, re)
9094
})
9195
}
9296

@@ -129,7 +133,7 @@ export class ChartsService {
129133

130134
/**
131135
* Get the URL for retrieving the chart's icon
132-
*
136+
*
133137
* @param {Chart} chart Chart object
134138
*/
135139
getChartIconURL(chart: Chart): string {

0 commit comments

Comments
 (0)