web/roomlist: lowercase search queries before unhomoglyphing

This commit is contained in:
Tulir Asokan 2024-10-20 12:38:04 +03:00
parent c0a8deb347
commit 251c91490c

View file

@ -46,8 +46,7 @@ export interface RoomListEntry {
const removeHiddenCharsRegex = /[\u2000-\u200F\u202A-\u202F\u0300-\u036F\uFEFF\u061C\u2800\u2062-\u2063\s]/g const removeHiddenCharsRegex = /[\u2000-\u200F\u202A-\u202F\u0300-\u036F\uFEFF\u061C\u2800\u2062-\u2063\s]/g
export function toSearchableString(str: string): string { export function toSearchableString(str: string): string {
return unhomoglyph(str.normalize("NFD").replace(removeHiddenCharsRegex, "")) return unhomoglyph(str.normalize("NFD").toLowerCase().replace(removeHiddenCharsRegex, ""))
.toLowerCase()
.replace(/[\\'!"#$%&()*+,\-./:;<=>?@[\]^_`{|}~\u2000-\u206f\u2e00-\u2e7f]/g, "") .replace(/[\\'!"#$%&()*+,\-./:;<=>?@[\]^_`{|}~\u2000-\u206f\u2e00-\u2e7f]/g, "")
.toLowerCase() .toLowerCase()
} }