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 www.google is valid #623

Closed
thisbejim opened this issue Feb 10, 2017 · 3 comments
Closed

isURL www.google is valid #623

thisbejim opened this issue Feb 10, 2017 · 3 comments

Comments

@thisbejim
Copy link

www.google is valid with the default isURL settings.

@thisbejim
Copy link
Author

Additionally, with the following setup:

{
    protocols: ['https'],
    require_protocol: true,
    require_tld: true,
    require_host: true,
 }

The following is valid: https://www.google. You would expect the validator to require the tld.

@chriso
Copy link
Collaborator

chriso commented Feb 10, 2017

https://www.google is a valid URL, and .google might be a valid TLD. See #429 and #428. The only way for the library to determine whether or not .google is a valid TLD would be to include a big list of them, which would bloat the size of the library. Another alternative would be to make a request to the URL to see if it resolves and responds to the request, but this is outside the scope of the library.

@chriso chriso closed this as completed Feb 10, 2017
@thisbejim
Copy link
Author

thisbejim commented Feb 10, 2017

Ah cool thanks for the explanation and apologies for not searching the issues thoroughly enough.

Given the confusion and the generally expected behaviour from a few different users, it might be worth adding an option for a mode that blacklists www as the start of the hostname (e.g. www.google) unless there is another . in the host name www.google.com. This gets around having to track tlds and bloating the library. Or if you'd prefer not to add anything extra to the library you could maybe document how to blacklist these domains in the readme.

e.g.

host_whitelist: [/(?:\w+\.)+\w+\./]

^ not sure how good that is

Anyway, just a thought! Cheers 👍

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

No branches or pull requests

2 participants