Skip to content

Commit

Permalink
Merge pull request #555 from eh2077/21234-fix-no-content-added-error-…
Browse files Browse the repository at this point in the history
…for-empty-alias-of-email-markdown

fix: 'No content to add' error if we send empty alias for email
  • Loading branch information
Gonals authored Jul 4, 2023
2 parents 52e551c + 3b8db3a commit 06a5ff5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions __tests__/ExpensiMark-HTML-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,9 @@ test('Test markdown style email link with various styles', () => {
+ '[Expensify!]([email protected]) '
+ '[Expensify?]([email protected]) '
+ '[Applause]([email protected]) '
+ '[]([email protected])' // empty in []
+ '[ ]([email protected])' // only spaces in []
+ '[]([email protected])' // only parse autoEmail in ()
+ '[ ]([email protected])' // only parse autoEmail in () and keep spaces in []
+ '[ \n ]([email protected])' // only parse autoEmail in () and keep spaces in []
+ '[ Expensify ]([email protected])' // edge spaces in []
+ '[ Expensify Email ]([email protected])' // space between words in []
+ '[[email protected]]([email protected])' // same email between [] and ()
Expand All @@ -526,8 +527,9 @@ test('Test markdown style email link with various styles', () => {
+ '<a href="mailto:[email protected]">Expensify!</a> '
+ '<a href="mailto:[email protected]">Expensify?</a> '
+ '<a href="mailto:[email protected]">Applause</a> '
+ '<a href="mailto:[email protected]"></a>'
+ '<a href="mailto:[email protected]"></a>'
+ '[](<a href="mailto:[email protected]">[email protected]</a>)'
+ '[ ](<a href="mailto:[email protected]">[email protected]</a>)'
+ '[ <br /> ](<a href="mailto:[email protected]">[email protected]</a>)'
+ '<a href="mailto:[email protected]">Expensify</a>'
+ '<a href="mailto:[email protected]">Expensify Email</a>'
+ '<a href="mailto:[email protected]">[email protected]</a>'
Expand Down
2 changes: 1 addition & 1 deletion lib/ExpensiMark.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class ExpensiMark {
name: 'email',
process: (textToProcess, replacement) => {
const regex = new RegExp(
`\\[([^[\\]]*)]\\(${CONST.REG_EXP.MARKDOWN_EMAIL}\\)`, 'gim'
`(?!\\[\\s*\\])\\[([^[\\]]*)]\\(${CONST.REG_EXP.MARKDOWN_EMAIL}\\)`, 'gim'
);
return this.modifyTextForEmailLinks(regex, textToProcess, replacement);
},
Expand Down

0 comments on commit 06a5ff5

Please sign in to comment.