GoogleChromeLabs / native-url

Node's url module implemented using the built-in URL API.
https://npm.im/native-url
Apache License 2.0
284 stars 11 forks source link

Error with 0.2.4: Can't parse "https://www.w.org" #15

Closed asselstine closed 4 years ago

asselstine commented 4 years ago

Expected Behavior

url.parse('https://www.w.org') should yield:

{ slashes: true,
  host: 'www.e.org',
  hostname: 'www.e.org',
  protocol: 'https:',
  search: null,
  hash: null,
  query: null,
  pathname: '/',
  path: '/',
  auth: null,
  port: null,
  href: 'https://www.e.org/' }

Actual Behavior

The above actually returns:

But instead we get:

{ slashes: true,
  host: null,
  hostname: null,
  protocol: 'https:',
  search: null,
  hash: null,
  query: null,
  pathname: '/',
  path: '/',
  auth: null,
  port: null,
  href: 'https:///' }

Steps to Reproduce the Problem

Try parsing a url whose hostname begins with 'www.w':

Fails: url.parse('https://www.w.org')

Succeeds: url.parse('https://w.org')

Specifications

Timer commented 4 years ago

This should also be tested with https://www.wikipedia.org/

janicklas-ralph commented 4 years ago

Thanks for posting this. This should be fixed.