Merge pull request #133 from lbryio/wash_better

Wash better
This commit is contained in:
Mark 2018-11-12 21:39:02 -05:00 committed by GitHub
commit 3f80062ac8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -318,8 +318,10 @@ function getStatus () {
function getWashedQuery (query) {
// compress multiple white spaces to 1
query = query.toLowerCase().replace(/ +/g, ' ');
let splitBy = ['&', '$', ' '];
let regex = new RegExp(splitBy.join('|'), 'gi');
let badWords = [ 'from', 'with', 'not', 'can', 'all', 'are', 'for', 'but', 'and', 'the' ];
let words = query.split(' ');
let words = query.split(regex);
let sentence = [];
words.forEach(w => {
if (!badWords.includes(w)) { sentence.push(w) }