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

isURL or isFQDN #949

Open
indefinitelee opened this issue Dec 13, 2018 · 2 comments
Open

isURL or isFQDN #949

indefinitelee opened this issue Dec 13, 2018 · 2 comments

Comments

@indefinitelee
Copy link

sorry this is more of a question than an issue, but what are the respective use cases of isURL with require_tld: true and isFQDN?

I'm trying to make sure a user submitted url ends with the tld and does not contain any params or paths after .com, for example.

@chriso
Copy link
Collaborator

chriso commented Dec 23, 2018

isFQDN validates domain names, whereas isURL validates URLs. If you look at the URL syntax, isFQDN would be used to validate just the host component:

> validator.isURL('http://google.com/')
true
> validator.isFQDN('google.com')
true

By default, isURL is lenient – it'll accept URL-like strings that would resolve when entered into your browser:

> validator.isURL('google.com')
true

You can use the options (require_protocol, etc.) to make it more strict.

A URL host could also be an IP address, which is accepted by isURL but not by isFQDN:

> v.isFQDN('127.0.0.1')
false
> v.isURL('127.0.0.1')
true

@chriso
Copy link
Collaborator

chriso commented Dec 23, 2018

So you're looking to allow strings like google.com and https://google.com, and reject URLs with a path component like https://google.com/ and https://google.com/search?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants