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); this.data = this.data.filter(item => item[key] === term);
break; break;
case 'string': case 'string':
if (term.length >= 3) { this.data = this.data.filter(item => {
this.data = this.data.filter(item => { let regFind = new RegExp(term, 'gi');
let regFind = new RegExp(term, 'gi'); let termMatches = (item[key].match(regFind) || []).length;
let termMatches = (item[key].match(regFind) || []).length; item.sortScore += termMatches;
item.sortScore += termMatches; return termMatches;
return termMatches; });
});
}
break; break;
} }
return this; return this;