Skip to content

UrlParser blows up with partial URL #3

@razzed

Description

@razzed

The following causes a TypeError when attempting to access u as an Array when it's null:

at Object.urlParser (as parse) in urlparser/index.js — line 129
TypeError: Cannot read property '1' of null

Code to replicate:

var urlparser = require("urlparser");
urlparser.parse("http:")

or

var urlparser = require("urlparser");
urlparser.parse("https:")

Would suggest simply checking for null from RegEx execution and return empty object in this case. I use this to validate URLs as a user is typing them in and so it blows up as they type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions