Search works with any length of term

This commit is contained in:
sharpshark28 2017-08-17 18:01:46 -05:00
parent b5767a6ad0
commit 810e7c7b5a

View file

@ -26,14 +26,12 @@ module.exports = class Query {
this.data = this.data.filter(item => item[key] === term);
break;
case 'string':
if (term.length >= 3) {
this.data = this.data.filter(item => {
let regFind = new RegExp(term, 'gi');
let termMatches = (item[key].match(regFind) || []).length;
item.sortScore += termMatches;
return termMatches;
});
}
break;
}
return this;