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

Allow localhost without adding require_tld:false #1731

Closed
maxgalbu opened this issue Sep 20, 2021 · 2 comments · Fixed by #1748
Closed

Allow localhost without adding require_tld:false #1731

maxgalbu opened this issue Sep 20, 2021 · 2 comments · Fixed by #1748

Comments

@maxgalbu
Copy link

maxgalbu commented Sep 20, 2021

Describe the bug
During development, I want to validate localhost as a correct URL, but to do so I need to add require_tld:false.
This forces me to make require_tld variable based on the environment, since I want to check for TLDs in production environment.

I think you should check the whitelist before checking if it's a IP or FQDN here:

if (!isIP(host) && !isFQDN(host, options) && (!ipv6 || !isIP(ipv6, 6))) {

I can open a Pull request if you agree!

Additional context
Validator.js version: 13.6
Node.js version: 16
OS platform: macOS

@tux-tn
Copy link
Member

tux-tn commented Sep 25, 2021

Thank you for your suggestion @maxgalbu
I agree in the fact that whitelist parameter should take precedence over isIP and isFQDN checks. Feel free to open a PR !

@deepanshu2506
Copy link
Contributor

I'll work on this...

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

Successfully merging a pull request may close this issue.

4 participants