1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-28 05:03:59 +03:00
This commit is contained in:
Matthew Hodgson
2016-03-17 01:02:38 +00:00
parent ad5d07caf8
commit ebc95667b8

View File

@@ -160,7 +160,9 @@ function PushProcessor(client) {
var displayName = room.currentState.getMember(client.credentials.userId).name; var displayName = room.currentState.getMember(client.credentials.userId).name;
var pat = new RegExp("\\b" + escapeRegExp(displayName) + "\\b", 'i'); // N.B. we can't use \b as it chokes on unicode. however \W seems to be okay
// as shorthand for [^0-9A-Za-z_].
var pat = new RegExp("(^|\\W)" + escapeRegExp(displayName) + "(\\W|$)", 'i');
return ev.content.body.search(pat) > -1; return ev.content.body.search(pat) > -1;
}; };
@@ -174,7 +176,7 @@ function PushProcessor(client) {
var pat; var pat;
if (cond.key == 'content.body') { if (cond.key == 'content.body') {
pat = '\\b' + globToRegexp(cond.pattern) + '\\b'; pat = '(^|\\W)' + globToRegexp(cond.pattern) + '(\\W|$)';
} else { } else {
pat = '^' + globToRegexp(cond.pattern) + '$'; pat = '^' + globToRegexp(cond.pattern) + '$';
} }