From 1db478b31d845c520ae8106d26e0fa1f53fce4b0 Mon Sep 17 00:00:00 2001 From: rhahao <26148770+rhahao@users.noreply.github.com> Date: Wed, 13 Dec 2023 21:15:05 +0300 Subject: [PATCH] fix(app): support non-ASCII characters for word boundary --- src/current/utils/sourceMaterial.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/current/utils/sourceMaterial.js b/src/current/utils/sourceMaterial.js index c6a338d4dc..438d7e9cc4 100644 --- a/src/current/utils/sourceMaterial.js +++ b/src/current/utils/sourceMaterial.js @@ -176,9 +176,10 @@ export const fetchData = async (language, issue) => { export const checkAYFExplainingBeliefsAssignment = (source) => { const { t } = getI18n(); + const boundary = '(?:^|\\s|$)'; const talk = t('talk', { lng: Setting.source_lang, ns: 'source' }); const demonstration = t('demonstration', { lng: Setting.source_lang, ns: 'source' }); - const searchKey = `\\b(${talk}|${demonstration})`; + const searchKey = boundary + `${talk}|${demonstration}` + boundary; const regex = new RegExp(searchKey, 'i'); const result = source.match(regex);