Skip to content

url.parse outputs incorrect url object #5755

@pawanrawal

Description

@pawanrawal
  • Version: 4.3.0
  • Platform: Darwin Apples-MacBook-Pro-2.local 14.5.0 Darwin Kernel Version 14.5.0: Tue Sep 1 21:23:09 PDT 2015; root:xnu-2782.50.1~1/RELEASE_X86_64 x86_64

When I try to parse a url which has a port but no protocol, node returns protocol as the host name as part of the url object.

url.parse('localhost:8080/api/user') returns

{
  protocol: 'localhost:',
  slashes: null,
  auth: null,
  host: '8080',
  port: null,
  hostname: '8080',
  hash: null,
  search: null,
  query: null,
  pathname: '/api/user',
  path: '/api/user',
  href: 'localhost:8080/api/user'
}

Host, protocol and port all here messed up here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidIssues and PRs that are invalid.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions