is-url icon indicating copy to clipboard operation
is-url copied to clipboard

Mention just how loose this component is

Open dandv opened this issue 11 years ago • 6 comments

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.

dandv avatar Feb 21 '14 04:02 dandv

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...

ianstormtaylor avatar Feb 21 '14 05:02 ianstormtaylor

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.

dandv avatar Feb 21 '14 07:02 dandv

https://github.com/segmentio/is-url/pull/9 will fix most of these issues.

kevva avatar Nov 22 '14 21:11 kevva

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.

dandv avatar Nov 23 '14 23:11 dandv

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.

  1. Worth closing this issue?
  2. Test cases with valid but rejected URLs welcome.

davisjam avatar Mar 20 '18 18:03 davisjam

Looks like validator has more traction. Too bad there's no TypeScript support.

dandv avatar May 28 '20 04:05 dandv