diff --git a/__tests__/ExpensiMark-HTML-test.js b/__tests__/ExpensiMark-HTML-test.js index 21bc8604..338f2f45 100644 --- a/__tests__/ExpensiMark-HTML-test.js +++ b/__tests__/ExpensiMark-HTML-test.js @@ -710,3 +710,9 @@ test('Test for link with no content', () => { const resultString = '[ ](www.link.com)'; 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); +}); diff --git a/lib/CONST.jsx b/lib/CONST.jsx index dedfea3d..30ba87ea 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 a228a642..7bcafcd7 100644 --- a/lib/ExpensiMark.js +++ b/lib/ExpensiMark.js @@ -83,7 +83,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; }