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 for email domains with no letters #5

Closed
wants to merge 1 commit into from
Closed
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 index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ function findEmail(_, atext, label, match) {
return false
}

// Do not link if label does not contain a letter.
if (!/[a-z]/i.test(label)) {
return false
}

return {
type: 'link',
title: null,
Expand Down
1 change: 1 addition & 0 deletions test/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ <h2>Email autolinks</h2>
<p><a href="mailto:a@a-b.c">a@a-b.c</a></p>
<p>Can’t end in an underscore followed by a period: aaa@a.b_.</p>
<p>Can contain an underscore followed by a period: <a href="mailto:aaa@a.b_.c">aaa@a.b_.c</a></p>
<p>Can't have a domain with no letters: mdast-util-gfm-autolink-literal@1.0.1</p>
<h2>Link text should not be expanded</h2>
<p><a href="http://www.example.com">Visit www.example.com</a> please.</p>
<p><a href="http://www.example.com">Visit http://www.example.com</a> please.</p>
Expand Down
2 changes: 2 additions & 0 deletions test/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ Can’t end in an underscore followed by a period: aaa@a.b_.

Can contain an underscore followed by a period: aaa@a.b_.c

Can't have a domain with no letters: mdast-util-gfm-autolink-literal@1.0.1

## Link text should not be expanded

[Visit www.example.com](http://www.example.com) please.
Expand Down