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

fix: emoji anchor text with hyperlink #536

Merged
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
5 changes: 5 additions & 0 deletions __tests__/ExpensiMark-HTML-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '[😀](<a href="https://www.link.com" target="_blank" rel="noreferrer noopener">www.link.com</a>)';
expect(parser.replace(testString)).toBe(resultString);
});
test('Test quotes markdown replacement with heading inside', () => {
let testString = '> # heading';
expect(parser.replace(testString)).toBe('<blockquote><h1>heading</h1></blockquote>');
Expand Down
7 changes: 7 additions & 0 deletions lib/CONST.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion lib/ExpensiMark.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down