Fixed #530 thanks to ChatGPT

This commit is contained in:
xmflsct 2022-12-06 21:54:32 +01:00
parent 5239fb83c6
commit c89612d875
4 changed files with 5 additions and 7 deletions

View File

@ -1,3 +1,2 @@
Enjoy toooting! This version includes following improvements and fixes:
- Fix toot attribution of favourites etc.
- Fix switching language
- Fix whole word filter matching

View File

@ -1,3 +1,2 @@
toooting愉快此版本包括以下改进和修复
- 修复嘟文收藏等显示
- 修复不能切换语言
- 修复过滤整词功能

View File

@ -1,6 +1,6 @@
{
"name": "tooot",
"version": "4.6.6",
"version": "4.7.0",
"description": "tooot for Mastodon",
"author": "xmflsct <me@xmflsct.com>",
"license": "GPL-3.0-or-later",

View File

@ -72,12 +72,12 @@ export const shouldFilter = ({
const escapedPhrase = filter.phrase.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') // $& means the whole matched string
switch (filter.whole_word) {
case true:
if (new RegExp(`\\B${escapedPhrase}\\b`).test(rawContent)) {
if (new RegExp(`\\b${escapedPhrase}\\b`, 'i').test(rawContent)) {
shouldFilter = filter.phrase
}
break
case false:
if (new RegExp(escapedPhrase).test(rawContent)) {
if (new RegExp(escapedPhrase, 'i').test(rawContent)) {
shouldFilter = filter.phrase
}
break