make mutes case insensitive

closes FoundKeyGang/FoundKey#392

Changelog: Changed
This commit is contained in:
Johann150 2023-05-31 12:58:50 +02:00
parent af003fc0fe
commit a0f0bac1ca
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1
2 changed files with 4 additions and 2 deletions

View file

@ -20,10 +20,11 @@ export async function checkWordMute(note: NoteLike, me: UserLike | null | undefi
const text = ((note.cw ?? '') + '\n' + (note.text ?? '')).trim();
if (text === '') return false;
const textLower = text.toLowerCase();
const matched = mutedWords.some(filter => {
if (Array.isArray(filter)) {
return filter.every(keyword => text.includes(keyword));
return filter.every(keyword => textLower.includes(keyword.toLowerCase()));
} else {
// represents RegExp
const regexp = filter.match(/^\/(.+)\/(.*)$/);

View file

@ -6,6 +6,7 @@ export function checkWordMute(note: Record<string, any>, me: Record<string, any>
const text = ((note.cw ?? '') + '\n' + (note.text ?? '')).trim();
if (text === '') return false;
const textLower = text.toLowerCase();
const matched = mutedWords.some(filter => {
if (Array.isArray(filter)) {
@ -13,7 +14,7 @@ export function checkWordMute(note: Record<string, any>, me: Record<string, any>
const filteredFilter = filter.filter(keyword => keyword !== '');
if (filteredFilter.length === 0) return false;
return filteredFilter.every(keyword => text.includes(keyword));
return filteredFilter.every(keyword => textLower.includes(keyword.toLowerCase()));
} else {
// represents RegExp
const regexp = filter.match(/^\/(.+)\/(.*)$/);