diff --git a/assets/chat/js/chat.js b/assets/chat/js/chat.js index 2411c67c..2e6740b0 100644 --- a/assets/chat/js/chat.js +++ b/assets/chat/js/chat.js @@ -49,6 +49,7 @@ import makeSafeForRegex, { nickregex, nsfwregex, nsflregex, + linkregex, } from './regex'; import { HashLinkConverter, MISSING_ARG_ERROR } from './hashlinkconverter'; @@ -2345,7 +2346,7 @@ class Chat { // Check current user nick against msg.message (if highlight setting is on) ((this.regexhighlightself && this.settings.get('highlight') && - this.regexhighlightself.test(message.message)) || + this.regexhighlightself.test(message.message.replace(linkregex, ''))) || // Check /highlight nicks against msg.nick (this.regexhighlightnicks && this.regexhighlightnicks.test(message.user.username)) || @@ -2374,7 +2375,9 @@ class Chat { } extractNicks(text) { - const uniqueNicks = new Set(text.match(nickmessageregex)); + const uniqueNicks = new Set( + text.replace(linkregex, '').match(nickmessageregex), + ); return [...uniqueNicks]; } diff --git a/assets/chat/js/regex.js b/assets/chat/js/regex.js index cea543ff..2783ecab 100644 --- a/assets/chat/js/regex.js +++ b/assets/chat/js/regex.js @@ -1,3 +1,5 @@ +import { UrlFormatter } from './formatters'; + const regexslashcmd = /^\/([a-z0-9]+)[\s]?/i; const regextime = /(?\d+)(?s(econds?)?$|m(inutes?)?$|h(ours?)?$|d(ays?)?$)?/i; @@ -5,6 +7,7 @@ const nickmessageregex = /(?=@?)(\w{3,20})/g; const nickregex = /^\w{3,20}$/; const nsfwregex = /\bNSFW\b/i; const nsflregex = /\bNSFL\b/i; +const { linkregex } = new UrlFormatter(); export { regexslashcmd, @@ -13,6 +16,7 @@ export { nickregex, nsfwregex, nsflregex, + linkregex, }; export default function makeSafeForRegex(str) {