Skip to content
This repository was archived by the owner on Oct 30, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 2 additions & 20 deletions ts/util/cleanSearchTerm.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
export function cleanSearchTerm(searchTerm: string) {
const lowercase = searchTerm.toLowerCase();
const withoutSpecialCharacters = lowercase.replace(/([!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~])/g, ' ');
const whiteSpaceNormalized = withoutSpecialCharacters.replace(/\s+/g, ' ');
const byToken = whiteSpaceNormalized.split(' ');
// be aware that a user typing Note To Self will have an issue when the `not` part of it is typed as the not word is reserved
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();
const whiteSpaceNormalized = searchTerm.replace(/\s+/g, ' ');
return whiteSpaceNormalized.trim();
}