Skip to content

Commit

Permalink
Fix email labels with final digits
Browse files Browse the repository at this point in the history
Related to micromark/micromark-extension-gfm-autolink-literal#7.
Related to remarkjs/remark#862.
Closes GH-5.

Co-authored-by: Rich Trott <[email protected]>
  • Loading branch information
wooorm and Trott committed Sep 24, 2021
1 parent e38f737 commit 7555d45
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 2 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,12 @@ function findUrl(_, protocol, domain, path, match) {
* @param {RegExpMatchObject} match
*/
function findEmail(_, atext, label, match) {
// Not an expected previous character.
if (!previous(match, true) || /[_-]$/.test(label)) {
if (
// Not an expected previous character.
!previous(match, true) ||
// Label ends in not allowed character.
/[_-\d]$/.test(label)
) {
return false
}

Expand Down
39 changes: 39 additions & 0 deletions test/email-tld-digits.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<p>[email protected]</p>
<p><a href="mailto:[email protected]">[email protected]</a></p>
<p>[email protected]</p>
<p><a href="mailto:[email protected]">[email protected]</a></p>
<p><a href="mailto:[email protected]">[email protected]</a></p>
<p>[email protected]</p>
<p>[email protected]</p>
<p>[email protected]</p>
<p>[email protected]</p>
<p>[email protected]</p>
<p>[ [email protected]</p>
<p>[ [email protected]</p>
<p>[ [email protected]</p>
<p>[ [email protected]</p>
<p>[ [email protected]</p>
<hr>
<p>react@a</p>
<p>react@1</p>
<p><a href="mailto:[email protected]">[email protected]</a></p>
<p>[email protected]</p>
<p><a href="mailto:[email protected]">[email protected]</a></p>
<p><a href="mailto:[email protected]">[email protected]</a></p>
<p><a href="mailto:[email protected]">[email protected]</a></p>
<p><a href="mailto:[email protected]">[email protected]</a></p>
<p>[email protected]</p>
<p><a href="mailto:[email protected]">[email protected]</a></p>
<p>[email protected]</p>
<hr>
<p>[ react@a</p>
<p>[ react@1</p>
<p>[ <a href="mailto:[email protected]">[email protected]</a></p>
<p>[ [email protected]</p>
<p>[ <a href="mailto:[email protected]">[email protected]</a></p>
<p>[ <a href="mailto:[email protected]">[email protected]</a></p>
<p>[ <a href="mailto:[email protected]">[email protected]</a></p>
<p>[ <a href="mailto:[email protected]">[email protected]</a></p>
<p>[ [email protected]</p>
<p>[ <a href="mailto:[email protected]">[email protected]</a></p>
<p>[ [email protected]</p>

0 comments on commit 7555d45

Please sign in to comment.