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

Email links followed by a hyphen are not detected #93

Open
mbroshi opened this issue Aug 26, 2020 · 5 comments
Open

Email links followed by a hyphen are not detected #93

mbroshi opened this issue Aug 26, 2020 · 5 comments

Comments

@mbroshi
Copy link

mbroshi commented Aug 26, 2020

When there is a valid email address, such as name@example.com, if it is followed by a hyphen, linkify.test returns false:

console.log(linkify.test('name@example.com'));   // true
console.log(linkify.test('name@example.com,'));  // true
console.log(linkify.test('name@example.com-'));  // false

I would expect both to be true.

You can test this by adding these two lines to test/fixtures/lines.txt:

name@example.com-
name@example.com
@puzrin
Copy link
Member

puzrin commented Aug 26, 2020

Please explain use case. Because looks like broken content. Linkifier is expected to be used with valid human-readable texts.

@mbroshi
Copy link
Author

mbroshi commented Aug 26, 2020

This came up in HabitRPG/habitica#12437

Someone has a sentence with an email address--name@example.com--and expects the address to have a link.

Also, every other punctuation I've added as a suffix after the link still tests as true. It's just hyphens that make the text test as false.

@mbroshi
Copy link
Author

mbroshi commented Aug 26, 2020

Looks like GitHub's link parser also has amusing behavior when hyphens are involved 😆

@mbroshi
Copy link
Author

mbroshi commented Sep 7, 2020

It's curious that it's just hyphens. To be honest, I have trouble parsing the regexes, so I can't be of much help. The simplest I idea I have is to strip trailing hyphens (which are not part of TLD/SLDs), if that's a feasible solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants