alert_words: Revert back `before_punctuation` regex to stable one.

In this 009b7bca24 commit `before_punctuation`
regex was updated to use lookbehind feature of regex.

This caused a regex error in some browsers (reported in
Safari) because lookbehind feature is not yet supported
on all the browsers (https://caniuse.com/js-regexp-lookbehind).

This commit fixes that error by reverting to stable regex which
works on all the browsers.
This commit is contained in:
Riken Shah 2021-05-06 19:55:35 +00:00 committed by Tim Abbott
parent 405bc8dabf
commit 37b265495b
1 changed files with 1 additions and 1 deletions

View File

@ -32,7 +32,7 @@ export function process_message(message) {
for (const word of my_alert_words) { for (const word of my_alert_words) {
const clean = _.escapeRegExp(word); const clean = _.escapeRegExp(word);
const before_punctuation = "(?<=\\s)|^|>|[\\(\\\".,';\\[]"; const before_punctuation = "\\s|^|>|[\\(\\\".,';\\[]";
const after_punctuation = "(?=\\s)|$|<|[\\)\\\"\\?!:.,';\\]!]"; const after_punctuation = "(?=\\s)|$|<|[\\)\\\"\\?!:.,';\\]!]";
const regex = new RegExp(`(${before_punctuation})(${clean})(${after_punctuation})`, "ig"); const regex = new RegExp(`(${before_punctuation})(${clean})(${after_punctuation})`, "ig");