validators icon indicating copy to clipboard operation
validators copied to clipboard

isUrl not validating tld

Open sreyseng opened this issue 6 years ago • 1 comments

Given the following website:

website = http://www.example

When I call isURL on it with the following options, I get true, when I expected to get false as this is not a valid URL. I understand the requireTld option defaults to true.

isURL(website, requireProtocol: true, allowUnderscore: true)

I am using version ^2.0.0+1

sreyseng avatar Aug 31 '19 05:08 sreyseng

I ran into this and was confused as well, and wound up here. But upon further thought, this is kind of tricky unless the package keeps a list of valid TLDs. For example, http://www.com is actually a valid URL (equivalent to www.www.com). Therefore so are all kinds of crazy domains like http://www.pizza.

One option could be to provide a way to ignore URLs of the pattern "www.TLD". Either as an optional parameter, or maybe the existing hostBlacklist could be modified to support wildcard patterns

doppio avatar Jan 27 '21 04:01 doppio