Skip to content

Commit

Permalink
make all email link variants return the same value
Browse files Browse the repository at this point in the history
  • Loading branch information
Skalakid committed Nov 15, 2023
1 parent f3af425 commit a09e11a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions __tests__/ExpensiMark-HTML-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -843,8 +843,8 @@ test('Test markdown style email link with various styles', () => {
+ '<a href="mailto:[email protected]">Expensify Email</a>'
+ '<a href="mailto:[email protected]">[email protected]</a>'
+ '<a href="mailto:[email protected]">[email protected]</a>'
+ '<a href="mailto:[email protected]">mailto:[email protected]</a>'
+ '<a href="mailto:[email protected]">mailto:[email protected]</a>'
+ '<a href="mailto:[email protected]">[email protected]</a>'
+ '<a href="mailto:[email protected]">[email protected]</a>'
+ '<a href="mailto:[email protected]">[email protected]</a>'
+ '<a href="mailto:[email protected]">(Expensify)</a>'
+ '[Expensify <a href="mailto:[email protected]">Test</a> Test](<a href="mailto:[email protected]">[email protected]</a>)'
Expand Down
7 changes: 6 additions & 1 deletion lib/ExpensiMark.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ export default class ExpensiMark {
if (g1.match(CONST.REG_EXP.EMOJIS) || !g1.trim()) {
return match;
}
return `<a href="mailto:${g2}">${g1.trim()}</a>`;
let label = g1.trim();
const href = `mailto:${g2}`;
if (label === href) {
label = g2;
}
return `<a href="${href}">${label}</a>`;
},
},

Expand Down

0 comments on commit a09e11a

Please sign in to comment.