Skip to content

Commit

Permalink
Issue #11569: Changing Mentions.userMentionRegex pattern to include <…
Browse files Browse the repository at this point in the history
…br> tag
  • Loading branch information
rssilva committed Sep 13, 2018
1 parent 02ff65c commit 9f1d1d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/rocketchat-mentions/Mentions.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class {
return typeof this._useRealName === 'function' ? this._useRealName() : this._useRealName;
}
get userMentionRegex() {
return new RegExp(`(^|\\s|<p>)@(${ this.pattern })`, 'gm');
return new RegExp(`(^|\\s|<p>|<br> ?)@(${ this.pattern })`, 'gm');
}
get channelMentionRegex() {
return new RegExp(`(^|\\s|<p>)#(${ this.pattern })`, 'gm');
Expand Down
8 changes: 8 additions & 0 deletions packages/rocketchat-mentions/tests/client.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,14 @@ describe('replace methods', function() {
assert.equal(result, `hello <a class="mention-link " data-username="${ specialchars.replace('@', '') }" title="${ specialchars.replace('@', '') }">${ specialcharsName }</a>`);
});

it(`should render for "hello<br>${ str2 } <br>"`, () => {
const result = mention.replaceUsers(`hello<br>${ str2 } <br>`, message, 'me');
const replaced = str2.replace('@', '');
const expected = `hello<br><a class="mention-link " data-username="${ replaced }" title="${ replaced }">${ str2Name }</a> <br>`;

assert.equal(result, expected);
});

it('should render for unknow/private user "hello @unknow"', () => {
const result = mention.replaceUsers('hello @unknow', message, 'me');
assert.equal(result, 'hello @unknow');
Expand Down

0 comments on commit 9f1d1d0

Please sign in to comment.