Move left pane entirely to React
This commit is contained in:
parent
bf904ddd12
commit
b3ac1373fa
142 changed files with 5016 additions and 3428 deletions
24
ts/util/cleanSearchTerm.ts
Normal file
24
ts/util/cleanSearchTerm.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
export function cleanSearchTerm(searchTerm: string) {
|
||||
const lowercase = searchTerm.toLowerCase();
|
||||
const withoutSpecialCharacters = lowercase.replace(
|
||||
/([!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~])/g,
|
||||
' '
|
||||
);
|
||||
const whiteSpaceNormalized = withoutSpecialCharacters.replace(/\s+/g, ' ');
|
||||
const byToken = whiteSpaceNormalized.split(' ');
|
||||
const withoutSpecialTokens = byToken.filter(
|
||||
token =>
|
||||
token &&
|
||||
token !== 'and' &&
|
||||
token !== 'or' &&
|
||||
token !== 'not' &&
|
||||
token !== ')' &&
|
||||
token !== '(' &&
|
||||
token !== '+' &&
|
||||
token !== ',' &&
|
||||
token !== 'near'
|
||||
);
|
||||
const withWildcards = withoutSpecialTokens.map(token => `${token}*`);
|
||||
|
||||
return withWildcards.join(' ').trim();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue