Skip to content

url.parse parses hostname as protocol when protocol/scheme is absent in hostname:port formatted uRL #2465

Description

@dap

I've observed that if a URL with port specified, and scheme unspecified, is supplied to url.parse, the hostname is set as protocol, and port as hostname in the result:

$ node > var url = require('url');
undefined
> url.parse('localhost:8080/foo/bar');
{ protocol: 'localhost:',
slashes: null,
auth: null,
host: '8080',
port: null,
hostname: '8080',
hash: null,
search: null,
query: null,
pathname: '/foo/bar',
path: '/foo/bar',
href: 'localhost:8080/foo/bar' }
> 

I'm unsure of whether this is a bug, but I figured I'd report the behavior. I'm using version v0.12.7, on OS X.

Metadata

Metadata

Assignees

No one assigned

    Labels

    urlIssues and PRs related to the legacy built-in url module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions