Skip to content

Commit 7555d45

Browse files
wooormTrott
andcommitted
Fix email labels with final digits
Related to micromark/micromark-extension-gfm-autolink-literal#7. Related to remarkjs/remark#862. Closes GH-5. Co-authored-by: Rich Trott <[email protected]>
1 parent e38f737 commit 7555d45

File tree

3 files changed

+122
-2
lines changed

3 files changed

+122
-2
lines changed

index.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,12 @@ function findUrl(_, protocol, domain, path, match) {
153153
* @param {RegExpMatchObject} match
154154
*/
155155
function findEmail(_, atext, label, match) {
156-
// Not an expected previous character.
157-
if (!previous(match, true) || /[_-]$/.test(label)) {
156+
if (
157+
// Not an expected previous character.
158+
!previous(match, true) ||
159+
// Label ends in not allowed character.
160+
/[_-\d]$/.test(label)
161+
) {
158162
return false
159163
}
160164

test/email-tld-digits.html

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
<p><a href="mailto:[email protected]">[email protected]</a></p>
3+
4+
<p><a href="mailto:[email protected]">[email protected]</a></p>
5+
<p><a href="mailto:[email protected]">[email protected]</a></p>
6+
7+
8+
9+
10+
11+
12+
13+
14+
15+
16+
<hr>
17+
<p>react@a</p>
18+
<p>react@1</p>
19+
<p><a href="mailto:[email protected]">[email protected]</a></p>
20+
21+
<p><a href="mailto:[email protected]">[email protected]</a></p>
22+
<p><a href="mailto:[email protected]">[email protected]</a></p>
23+
<p><a href="mailto:[email protected]">[email protected]</a></p>
24+
<p><a href="mailto:[email protected]">[email protected]</a></p>
25+
26+
<p><a href="mailto:[email protected]">[email protected]</a></p>
27+
28+
<hr>
29+
<p>[ react@a</p>
30+
<p>[ react@1</p>
31+
<p>[ <a href="mailto:[email protected]">[email protected]</a></p>
32+
33+
<p>[ <a href="mailto:[email protected]">[email protected]</a></p>
34+
<p>[ <a href="mailto:[email protected]">[email protected]</a></p>
35+
<p>[ <a href="mailto:[email protected]">[email protected]</a></p>
36+
<p>[ <a href="mailto:[email protected]">[email protected]</a></p>
37+
38+
<p>[ <a href="mailto:[email protected]">[email protected]</a></p>
39+

test/email-tld-digits.md

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
2+
3+
4+
5+
6+
7+
8+
9+
10+
11+
12+
13+
14+
15+
16+
17+
18+
19+
20+
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
---
32+
33+
react@a
34+
35+
react@1
36+
37+
38+
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
54+
55+
---
56+
57+
[ react@a
58+
59+
[ react@1
60+
61+
62+
63+
64+
65+
66+
67+
68+
69+
70+
71+
72+
73+
74+
75+
76+
77+

0 commit comments

Comments
 (0)