matchBeginningOfWords more compact

This commit is contained in:
Moriz Wahl 2020-03-16 12:12:01 +01:00 committed by mattwr18
parent 0a15d785a3
commit 48564565a5

View File

@ -37,19 +37,11 @@ const matchSomeWordsExactly = (str, boost = 2) => {
}
const matchBeginningOfWords = str => {
return normalizeWhitespace(
str
.split(' ')
.map(s => {
if (s.length > 3) {
// at least 4 letters. So AND, OR and NOT are never used unquoted
return s + '*'
} else {
return ''
}
})
.join(' '),
)
return str
.split(' ')
.filter(s => s.length > 3)
.map(s => s + '*')
.join(' ')
}
export function normalizeWhitespace(str) {