Skip to content

Commit cfd29b9

Browse files
committed
improve search trim filter
1 parent 7ee1e81 commit cfd29b9

File tree

1 file changed

+5
-2
lines changed
  • src/electron-preload/database-indexer/lib

1 file changed

+5
-2
lines changed

src/electron-preload/database-indexer/lib/util.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ export const SERVICES_FACTORY = {
3535
};
3636

3737
const trimNonLetterCharactersFilter: (value: string) => string = (() => {
38-
const re = /(^\P{L}+)|(\P{L}+$)/gu;
39-
return (value: string) => value.replace(re, "");
38+
// TODO make sure all the possible unicode categories listed here except {L} and {N}
39+
const toTrim = "[\\p{M}\\p{Z}\\p{S}\\p{P}\\p{C}]+";
40+
const startEndTrimmingRe = new RegExp(`(^${toTrim})|(${toTrim}$)`, "gu");
41+
42+
return (value: string) => value.replace(startEndTrimmingRe, "");
4043
})();
4144

4245
export function createMailsIndex(): MailsIndex {

0 commit comments

Comments
 (0)