Thanks to visit codestin.com
Credit goes to github.com

Skip to content

An exception is thrown when using URI() without the new keyword #205

@KyleNeedham

Description

@KyleNeedham

When URI is used without the new keyword it will return a new instance of itself passing both an url and base parameter.

if (!(this instanceof URI)) {
  return new URI(url, base);
}

Since these parameters are both undefined at this point, it is caught by the undefined check on the url and then also passes the check on the arguments length, throwing a TypeError.

if (url === undefined) {
  if (arguments.length) {
    throw new TypeError('undefined is not a valid argument for URI');
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions