Mention just how loose this component is
var matcher = /^\w+:\/\/([^\s\.]+\.\S{2}|localhost[\:?\d]*)\S*$/;
Will fail SO badly in so many cases: IDNs, modern TLDs, parens in URLs, punctuation at the end etc.
There's a much more powerful regexp in component/regexps.uri.
I understand this component doesn't really aim to properly parse URLs like linkify, but perhaps it's better to just use the regexps component.
can you give some examples? and do you have a fix for the IDNs? open to PRs
i think parens are valid in urls?
if anything, component/regexps is going to fail on new TLDs, it already fails on localhost, rare protocols, etc...
I think I found a library that's better than Component, maybe we can focus our efforts on improving that one - http://soapbox.github.io/jQuery-linkify/. A simple regexp just won't cut it.
https://github.com/segmentio/is-url/pull/9 will fix most of these issues.
Whether #9 will fix those issues I don't know. My point is, why develop yet another "is this string a URL" library when there are so many out there, and better at that to boot.
Why develop yet another "is this string a URL" library
Perhaps this observation is too late now. This module gets 2M downloads/month on npm.
- Worth closing this issue?
- Test cases with valid but rejected URLs welcome.
Looks like validator has more traction. Too bad there's no TypeScript support.