Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit b13dae1

Browse files
committed
Ignore punctuation when filtering rooms
Signed-off-by: Robin Townsend <[email protected]>
1 parent 2ab3041 commit b13dae1

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/stores/room-list/filters/NameFilterCondition.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,17 @@ export class NameFilterCondition extends EventEmitter implements IFilterConditio
6666
return this.matches(room.name);
6767
}
6868

69-
public matches(val: string): boolean {
69+
private normalize(val: string): string {
7070
// Note: we have to match the filter with the removeHiddenChars() room name because the
7171
// function strips spaces and other characters (M becomes RN for example, in lowercase).
72-
// We also doubly convert to lowercase to work around oddities of the library.
73-
const noSecretsFilter = removeHiddenChars(this.search.toLowerCase()).toLowerCase();
74-
const noSecretsName = removeHiddenChars(val.toLowerCase()).toLowerCase();
75-
return noSecretsName.includes(noSecretsFilter);
72+
return removeHiddenChars(val.toLowerCase())
73+
// Strip all punctuation
74+
.replace(/[\\'!"#$%&()*+,\-./:;<=>?@[\]^_`{|}~\u2000-\u206f\u2e00-\u2e7f]/g, "")
75+
// We also doubly convert to lowercase to work around oddities of the library.
76+
.toLowerCase();
77+
}
78+
79+
public matches(val: string): boolean {
80+
return this.normalize(val).includes(this.normalize(this.search));
7681
}
7782
}

0 commit comments

Comments
 (0)