Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Changing Mentions.userMentionRegex pattern to include <br> tag #12043

Merged
merged 2 commits into from
Sep 19, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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