Skip to content

Allow localhost without adding require_tld:false #1731

@maxgalbu

Description

@maxgalbu

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions