Validator.js: isURL returns true for an invalid URL

Created on 22 Aug 2019  ·  9Comments  ·  Source: validatorjs/validator.js

isURL('http://www.domain') returns as a valid URL

🍿 discussion 🐛 bug

Most helpful comment

Thinking about this again, yes, http://www.domain should be a valid URL, since you can actually have a domain like www.com, therefore it means you can still have www.<any-top-level>. As much as there is no current .domain, there's no rule that prohibits this.

Perhaps I'm mistaken, but let me know if this makes sense.

@rubiin when taking a look at this, also look at http://www.domain.com.com.com.com, i.e
the occurrence of many instances of . in a URL.
It makes it true although I don't think if it is a valid URL.

  • com.com is a valid domain; the rest then just become sub-domains...

All 9 comments

PR welcome.

Will do a pr in a while

@rubiin when taking a look at this, also look at http://www.domain.com.com.com.com, i.e
the occurrence of many instances of . in a URL.
It makes it true although I don't think if it is a valid URL.

Thinking about this again, yes, http://www.domain should be a valid URL, since you can actually have a domain like www.com, therefore it means you can still have www.<any-top-level>. As much as there is no current .domain, there's no rule that prohibits this.

Perhaps I'm mistaken, but let me know if this makes sense.

@rubiin when taking a look at this, also look at http://www.domain.com.com.com.com, i.e
the occurrence of many instances of . in a URL.
It makes it true although I don't think if it is a valid URL.

  • com.com is a valid domain; the rest then just become sub-domains...

URL https://[email protected] validates as true.

> validator.isURL("https://[email protected]");
true
>

validator.isURL('adsf.asdf');
true
is there an option to actually check if URL responds with status 200?

@v3rron I believe ‘adsf.asdf’ is pretty much legit url. Checking if domain name is actually exists and alive is far beyond the purposes of this library, the purpose is to check if a string complies with specific rules.

While it is technically valid i believe there should be some sort of option for this?

From what I've read the organization that approves new tlds (ICANN) only approves domain every few years for a sum of $200k.

It would make sense to have an option for this such as: require_official_tld with default set to false

@Subalee -- you have a point; may be we need to re-think this... Let me here what the rest suggest.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rathboma picture rathboma  ·  4Comments

karladler picture karladler  ·  3Comments

woverton picture woverton  ·  4Comments

AtomicBorg picture AtomicBorg  ·  3Comments

mfbx9da4 picture mfbx9da4  ·  4Comments