diff --git a/__tests__/ExpensiMark-HTML-test.js b/__tests__/ExpensiMark-HTML-test.js index b5ab752a..8248d215 100644 --- a/__tests__/ExpensiMark-HTML-test.js +++ b/__tests__/ExpensiMark-HTML-test.js @@ -741,6 +741,11 @@ test('Test for link with no content', () => { expect(parser.replace(testString)).toBe(resultString); }); +test('Test for link with emoji', () => { + const testString = '[😀](www.link.com)'; + const resultString = '[😀](www.link.com)'; + expect(parser.replace(testString)).toBe(resultString); +}); test('Test quotes markdown replacement with heading inside', () => { let testString = '> # heading'; expect(parser.replace(testString)).toBe('

heading

'); diff --git a/lib/CONST.jsx b/lib/CONST.jsx index 45edcaa4..432998ce 100644 --- a/lib/CONST.jsx +++ b/lib/CONST.jsx @@ -331,6 +331,13 @@ export const CONST = { * @type String */ MARKDOWN_EMAIL: "([a-zA-Z0-9.!#$%&'+/=?^`{|}-][a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]*@[a-zA-Z0-9-]+?(\\.[a-zA-Z]+)+)", + + /** + * Regex matching an text containing an Emoji + * + * @type RegExp + */ + EMOJIS: /[\p{Extended_Pictographic}\u200d\u{1f1e6}-\u{1f1ff}\u{1f3fb}-\u{1f3ff}\u{e0020}-\u{e007f}\u20E3\uFE0F]|[#*0-9]\uFE0F?\u20E3/gu, }, REPORT: { diff --git a/lib/ExpensiMark.js b/lib/ExpensiMark.js index 4ce35820..52b90400 100644 --- a/lib/ExpensiMark.js +++ b/lib/ExpensiMark.js @@ -116,7 +116,7 @@ export default class ExpensiMark { // We use a function here to check if there is already a https:// on the link. // If there is not, we force the link to be absolute by prepending '//' to the target. replacement: (match, g1, g2, g3) => { - if (!g1.trim()) { + if (g1.match(CONST.REG_EXP.EMOJIS) || !g1.trim()) { return match; }