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

Issue-26016 make usermention case insensitive #591

Merged
merged 6 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 14 additions & 0 deletions __tests__/ExpensiMark-HTML-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1470,3 +1470,17 @@ test('Test autoEmail with markdown of <pre>, <code>, <a>, <mention-user> and <em

expect(parser.replace(testString)).toBe(resultString);
});

test('Mention', () => {
let testString = '@[email protected]';
expect(parser.replace(testString)).toBe('<mention-user>@[email protected]</mention-user>');

testString = '@[email protected]';
expect(parser.replace(testString)).toBe('<mention-user>@[email protected]</mention-user>');

testString = '@[email protected]';
expect(parser.replace(testString)).toBe('<mention-user>@[email protected]</mention-user>');

testString = '@[email protected]';
expect(parser.replace(testString)).toBe('<mention-user>@[email protected]</mention-user>');
});
14 changes: 14 additions & 0 deletions __tests__/ExpensiMark-HTMLToText-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,17 @@ test('Test remove style tag', () => {
const testString = '<div><svg><style>.default-avatar_20_svg__st1{fill:#008c59}</style></svg><p>a text</p></div>';
expect(parser.htmlToText(testString)).toBe('a text');
});

test('Mention html to text', () => {
let testString = '<mention-user>@[email protected]</mention-user>';
expect(parser.htmlToText(testString)).toBe('@[email protected]');

testString = '<mention-user>@[email protected]</mention-user>';
expect(parser.htmlToText(testString)).toBe('@[email protected]');

testString = '<mention-user>@[email protected]</mention-user>';
expect(parser.htmlToText(testString)).toBe('@[email protected]');

testString = '<mention-user>@[email protected]</mention-user>';
expect(parser.htmlToText(testString)).toBe('@[email protected]');
});
14 changes: 14 additions & 0 deletions __tests__/ExpensiMark-Markdown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,3 +690,17 @@ test('Test codeFence copy from selection does not add extra new line', () => {
testString = '<h3>test heading</h3><div><pre class=\"notranslate\"><code class=\"notranslate\">Code snippet\n</code></pre></div><blockquote><p><a href=\"https://www.example.com\">link</a></p></blockquote>';
expect(parser.htmlToMarkdown(testString)).toBe('test heading\n```\nCode snippet\n```\n> [link](https://www.example.com)')
});

test('Mention html to markdown', () => {
let testString = '<mention-user>@[email protected]</mention-user>';
expect(parser.htmlToMarkdown(testString)).toBe('@[email protected]');

testString = '<mention-user>@[email protected]</mention-user>';
expect(parser.htmlToMarkdown(testString)).toBe('@[email protected]');

testString = '<mention-user>@[email protected]</mention-user>';
expect(parser.htmlToMarkdown(testString)).toBe('@[email protected]');

testString = '<mention-user>@[email protected]</mention-user>';
expect(parser.htmlToMarkdown(testString)).toBe('@[email protected]');
});
2 changes: 1 addition & 1 deletion lib/ExpensiMark.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default class ExpensiMark {
*/
{
name: 'userMentions',
regex: new RegExp(`[a-zA-Z0-9.!$%&+/=?^\`{|}-]?@+${CONST.REG_EXP.EMAIL_PART}(?!((?:(?!<a).)+)?<\\/a>|[^<]*(<\\/pre>|<\\/code>))`, 'gm'),
regex: new RegExp(`[a-zA-Z0-9.!$%&+/=?^\`{|}-]?@+${CONST.REG_EXP.EMAIL_PART}(?!((?:(?!<a).)+)?<\\/a>|[^<]*(<\\/pre>|<\\/code>))`, 'gmi'),
replacement: (match) => {
if (!Str.isValidMention(match)) {
return match;
Expand Down
Loading