From 9f1d1d0470a0de1d7877f97a679666cbe44fa4be Mon Sep 17 00:00:00 2001 From: Rafael Specht Date: Thu, 13 Sep 2018 10:40:06 -0300 Subject: [PATCH] Issue #11569: Changing Mentions.userMentionRegex pattern to include
tag --- packages/rocketchat-mentions/Mentions.js | 2 +- packages/rocketchat-mentions/tests/client.tests.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/rocketchat-mentions/Mentions.js b/packages/rocketchat-mentions/Mentions.js index 775321cf0a06..b9773b847870 100644 --- a/packages/rocketchat-mentions/Mentions.js +++ b/packages/rocketchat-mentions/Mentions.js @@ -28,7 +28,7 @@ export default class { return typeof this._useRealName === 'function' ? this._useRealName() : this._useRealName; } get userMentionRegex() { - return new RegExp(`(^|\\s|

)@(${ this.pattern })`, 'gm'); + return new RegExp(`(^|\\s|

|
?)@(${ this.pattern })`, 'gm'); } get channelMentionRegex() { return new RegExp(`(^|\\s|

)#(${ this.pattern })`, 'gm'); diff --git a/packages/rocketchat-mentions/tests/client.tests.js b/packages/rocketchat-mentions/tests/client.tests.js index 9538445db162..4cb90912d5fc 100644 --- a/packages/rocketchat-mentions/tests/client.tests.js +++ b/packages/rocketchat-mentions/tests/client.tests.js @@ -239,6 +239,14 @@ describe('replace methods', function() { assert.equal(result, `hello ${ specialcharsName }`); }); + it(`should render for "hello
${ str2 }
"`, () => { + const result = mention.replaceUsers(`hello
${ str2 }
`, message, 'me'); + const replaced = str2.replace('@', ''); + const expected = `hello
${ str2Name }
`; + + 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');