mirror of
https://github.com/tooot-app/app
synced 2025-02-01 11:06:56 +01:00
Fix whole word filter not working
This commit is contained in:
parent
f96e9af7b9
commit
44d1f6fbed
@ -46,7 +46,7 @@ export const shouldFilter = ({
|
|||||||
let shouldFilter = false
|
let shouldFilter = false
|
||||||
if (!ownAccount) {
|
if (!ownAccount) {
|
||||||
const parser = new htmlparser2.Parser({
|
const parser = new htmlparser2.Parser({
|
||||||
ontext (text: string) {
|
ontext: (text: string) => {
|
||||||
const checkFilter = (filter: Mastodon.Filter) => {
|
const checkFilter = (filter: Mastodon.Filter) => {
|
||||||
const escapedPhrase = filter.phrase.replace(
|
const escapedPhrase = filter.phrase.replace(
|
||||||
/[.*+?^${}()|[\]\\]/g,
|
/[.*+?^${}()|[\]\\]/g,
|
||||||
@ -54,7 +54,7 @@ export const shouldFilter = ({
|
|||||||
) // $& means the whole matched string
|
) // $& means the whole matched string
|
||||||
switch (filter.whole_word) {
|
switch (filter.whole_word) {
|
||||||
case true:
|
case true:
|
||||||
if (new RegExp('\\b' + escapedPhrase + '\\b').test(text)) {
|
if (new RegExp('\\B' + escapedPhrase + '\\B').test(text)) {
|
||||||
shouldFilter = true
|
shouldFilter = true
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
Loading…
x
Reference in New Issue
Block a user