gregjacobs / Autolinker.js

Utility to Automatically Link URLs, Email Addresses, Phone Numbers, Twitter handles, and Hashtags in a given block of text/HTML
MIT License
1.48k stars 238 forks source link

Subdomains with underscores are not identified as links #299

Open haugstrup opened 4 years ago

haugstrup commented 4 years ago

This is related to #277 in that it's an issue with getDomainNameStr in regex-lib.ts.

Subdomain names are treated pretty lax out in the wild. It's common to see subdomains with underscores, but autolinker won't identify these links.

For example: http://_foo.example.com will identify foo.example.com as the link. And http://foo_bar.example.com will identify two links (http://foo and bar.example.com).

@gregjacobs Do you have any general hints on how to target subdomains separately from the normal domain name in getDomainNameStr? I can make the changes and write tests, but I'm having some trouble parsing the current logic.

pavholm commented 3 years ago

Have the same problem

Zheleznyak-F commented 2 years ago

I have the same problem, links with underscores break into multiple parts.

http://faq_for_users.domain.com -> converts into three parts, (faq and users.domain.com like links, and _for_ like plain text);

@gregjacobs Do you have any idea how to fix this problem? Maybe you can point out the origin of this problem.

@haugstrup Have you invented a workaround? Can you share it?

vickz84259 commented 2 years ago

Hey, just wanted to point out that this PR should address this issue. So if possible, @gregjacobs could review and merge it. Thank you.