Skip to content

Commit e71a6f2

Browse files
committed
fix short mention with single character followed by dot isn't recognized
1 parent e25a3e2 commit e71a6f2

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
@@ -1530,6 +1530,12 @@ describe('Tests for short mentions', () => {
15301530
const resultString = '<mention-short>@john.doe</mention-short><mention-here>@here</mention-here>';
15311531
expect(parser.replace(testString)).toBe(resultString);
15321532
});
1533+
1534+
test('short mentions should work for single character followed by dot', () => {
1535+
const testString = '@j.doe';
1536+
const resultString = '<mention-short>@j.doe</mention-short>';
1537+
expect(parser.replace(testString)).toBe(resultString);
1538+
});
15331539
});
15341540

15351541
// 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{3,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)