Skip to content

Commit 21d4002

Browse files
authored
Merge pull request #891 from ChavdaSachin/shortmention-reduce-prefix-min-length
improve shortmention regex to match short prefix(1,2 char) email addr…
2 parents 9959005 + 6078c08 commit 21d4002

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

__tests__/ExpensiMark-HTML-test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,12 @@ describe('Tests for short mentions', () => {
15181518
const resultString = '<mention-short>@j.doe</mention-short>';
15191519
expect(parser.replace(testString)).toBe(resultString);
15201520
});
1521+
1522+
test('short mentions should work for single character followed by dot', () => {
1523+
const testString = '@j';
1524+
const resultString = '<mention-short>@j</mention-short>';
1525+
expect(parser.replace(testString)).toBe(resultString);
1526+
});
15211527
});
15221528

15231529
// Examples that should match for here mentions:

lib/ExpensiMark.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ export default class ExpensiMark {
503503
name: 'shortMentions',
504504

505505
regex: new RegExp(
506-
`${Constants.CONST.REG_EXP.PRE_MENTION_TEXT_PART}(@(?=((?=[\\w]+[\\w'#%+-]*(?:\\.[\\w'#%+-]+)*)[\\w\\.'#%+-]{1,64}(?= |_|\\b))(?!([:\\/\\\\]))(?<end>.*))(?!here)\\S{3,254}(?=\\k<end>$))(?!((?:(?!<a).)+)?<\\/a>|[^<]*(<\\/pre>|<\\/code>|<\\/mention-user>|<\\/mention-here>))`,
506+
`${Constants.CONST.REG_EXP.PRE_MENTION_TEXT_PART}(@(?=((?=[\\w]+[\\w'#%+-]*(?:\\.[\\w'#%+-]+)*)[\\w\\.'#%+-]{1,64}(?= |_|\\b))(?!([:\\/\\\\]))(?<end>.*))(?!here)\\S{1,254}(?=\\k<end>$))(?!((?:(?!<a).)+)?<\\/a>|[^<]*(<\\/pre>|<\\/code>|<\\/mention-user>|<\\/mention-here>))`,
507507
'gim',
508508
),
509509
replacement: (_extras, match, g1, g2) => {

0 commit comments

Comments
 (0)