Match word boundaries for nick highlight (#819)

This commit is contained in:
Calvin Montgomery 2019-08-01 20:02:37 -07:00
parent 1ec3eab0dc
commit 08f9feef74
1 changed files with 6 additions and 1 deletions

View File

@ -1655,7 +1655,7 @@ function addChatMessage(data) {
var isHighlight = false;
if (CLIENT.name && data.username != CLIENT.name) {
if (data.msg.toLowerCase().indexOf(CLIENT.name.toLowerCase()) != -1) {
if (highlightsMe(data.msg)) {
div.addClass("nick-highlight");
isHighlight = true;
}
@ -1664,6 +1664,11 @@ function addChatMessage(data) {
pingMessage(isHighlight, data.username, $(div.children()[2]).text());
}
function highlightsMe(message) {
// TODO: distinguish between text and HTML attributes as noted in #819
return message.match(new RegExp("(^|\\b)" + CLIENT.name + "($|\\b)", "gi"));
}
function trimChatBuffer() {
var maxSize = window.CHATMAXSIZE;
if (!maxSize || typeof maxSize !== "number")