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

Url parsing #59

Open
Kelt opened this issue Jun 29, 2021 · 4 comments
Open

Url parsing #59

Kelt opened this issue Jun 29, 2021 · 4 comments

Comments

@Kelt
Copy link

Kelt commented Jun 29, 2021

if text is

aaa:google.com

and

url={true}

then entire text is linkified ... it really should be aaa: as string and google.com as link (tldMatches picks up .com correctly but fails to split the preceded text)

@joshswan
Copy link
Owner

joshswan commented Jun 29, 2021

URL matching is handled under the hood by Autolinker.js. From what I can tell, this is a side effect of matching URL schemes, so disabling schemeMatches fixes the issue, though that may not be optimal depending on your use case. You can also use a custom matcher with a custom regex for more control.

I'll do a bit of digging to see if there's anything that can be done here.

Related issue: gregjacobs/Autolinker.js#352

@Kelt
Copy link
Author

Kelt commented Jun 29, 2021

Yeah, tldMatches false fixes it but that's undesirable. SchemeMatches shouldn't have impact on this, will test. Proper fix would be in AutoLinker, thx for raising issue there 👍

@saiaryan
Copy link

Hi @Kelt @joshswan any update on this issue

@joshswan
Copy link
Owner

Unfortunately it doesn't look like there's been any progress on the Autolinker.js side. I'm exploring a few options on my end but basically everything I've come up with is going to be a breaking change.

My best suggestion for now is to disable the default URL parsing and implement a custom matcher that better suits your needs. The more restrictive regex /(https?:\/\/|www\.)[-a-zA-Z0-9@:%._\+~#=]{1,256}\.(xn--)?[a-z0-9-]{2,20}\b([-a-zA-Z0-9@:%_\+\[\],.~#?&\/=]*[-a-zA-Z0-9@:%_\+\]~#?&\/=])*/i handles this case correctly at the expense of requiring an http(s) or www at the start of a link.

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

3 participants