Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return this.model.filter(item => {
// check filters
if (filter && !get(item, `filterValues.${filter}`)) {
return false;
}
// check search
if (!isEmpty(search)) {
let searchString = this.recordToString(item);
return !!searchString.match(new RegExp(`.*${escapeRegExp(search.toLowerCase())}.*`));
}
return true;
});
}),
matchesExactly(val) {
return !!((this.get('label') || '').toLowerCase().match(new RegExp(`.*${escapeRegExp(val.toLowerCase())}.*`)));
},
escapedSearch: computed('search', function() {
return escapeRegExp(this.search.toLowerCase());
}),
export default function(text, searchQuery) {
if (isEmpty(searchQuery)) {
return true;
}
let regExp = new RegExp(escapeRegExp(sanitize(searchQuery)));
return !!sanitize(text).match(regExp);
}
searchMatch: computed('search', 'name', function() {
let search = this.search;
if (isEmpty(search)) {
return true;
}
let name = this.get('model.name');
let regExp = new RegExp(escapeRegExp(search.toLowerCase()));
return !!name.toLowerCase().match(regExp);
}),