Skip to content

isURL() doesn't accept URLs with only a username in the userinfo subcomponent #1643

@jbuchmann-coosto

Description

@jbuchmann-coosto

Describe the bug
A URL of the form http://[email protected] is rejected by isURL() even though it should be a valid URL according to RFC 1738 (section 3.1)

Some or all of the parts "<user>:<password>@", ":<password>", ":<port>", and "/<url-path>" may be excluded.

Examples
An example from the Node REPL:

$ node
Welcome to Node.js v12.20.0.
Type ".help" for more information.
> var validator = require('validator');
undefined
> validator.isURL('http://[email protected]')
false
> validator.isURL('http://user:@example.com')
true

Additional context
Validator.js version: 13.5.1
Node.js version: 12.20.0
OS platform: linux (Ubuntu 20.04)

Pull Request
I'll send a PR shortly.

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