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

Commit 3c25979

Browse files
authored
Merge pull request #5824 from robintown/ignore-punctuation
Ignore punctuation when filtering rooms
2 parents 6e6a26f + b13dae1 commit 3c25979

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
@@ -65,12 +65,17 @@ export class NameFilterCondition extends EventEmitter implements IFilterConditio
6565
return this.matches(room.name);
6666
}
6767

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

0 commit comments

Comments
 (0)