Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Port Numbers without Protocols not Parsed #69

Closed
DerekTBrown opened this issue Aug 3, 2017 · 3 comments
Closed

[BUG] Port Numbers without Protocols not Parsed #69

DerekTBrown opened this issue Aug 3, 2017 · 3 comments

Comments

@DerekTBrown
Copy link

It seems there was a breaking change to the way that port numbers are parsed. Take this example:

var URL = require('url-parse');
var url = new URL('localhost:8000');
console.log(url);

The current version (1.1.9) produces the following output:

{ slashes: false,
  protocol: 'localhost:',
  hash: '',
  query: '',
  pathname: '8000',
  auth: '',
  host: '',
  port: '',
  hostname: '',
  password: '',
  username: '',
  origin: 'null',
  href: 'localhost:8000' }

When previous versions (1.0.5), produce this:

URL {
  hash: '',
  query: '',
  protocol: '',
  pathname: '',
  auth: '',
  host: 'localhost:8000',
  port: '8000',
  hostname: 'localhost',
  password: '',
  username: '',
  href: '//localhost:8000' }
@lpinca
Copy link
Member

lpinca commented Aug 4, 2017

This changed with #22 but I would argue that it's not a breaking change but a bug fix.

Node.js url.parse():

> url.parse('localhost:8000')
Url {
  protocol: 'localhost:',
  slashes: null,
  auth: null,
  host: '8000',
  port: null,
  hostname: '8000',
  hash: null,
  search: null,
  query: null,
  pathname: null,
  path: null,
  href: 'localhost:8000' }

Firefox 54.0.1:

new URL('localhost:8000')
URL { href: "localhost:8000", origin: "null", protocol: "localhost:", username: "", password: "", host: "", hostname: "", port: "", pathname: "8000", search: "" }

@DerekTBrown
Copy link
Author

@lpinca so this is the expected behavior?

@lpinca
Copy link
Member

lpinca commented Aug 4, 2017

Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants