mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
matchBeginningOfWords more compact
This commit is contained in:
parent
0a15d785a3
commit
48564565a5
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user