Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

url.parse does not parse hostname correctly if path starts with colon character #9072

Closed
misterdjules opened this issue Jan 21, 2015 · 1 comment
Assignees
Milestone

Comments

@misterdjules
Copy link

A URL such as protocol://[email protected]:foo/bar is parsed correctly with node v0.11.14:

➜  v0.12 git:(v0.11.14-release) ✗ ./node --version
v0.11.14
➜  v0.12 git:(v0.11.14-release) ✗ ./node -p "require('url').parse('http://[email protected]:foo/bar')"
{ protocol: 'http:',
  slashes: true,
  auth: 'user',
  host: 'somehost.com',
  port: null,
  hostname: 'somehost.com',
  hash: null,
  search: null,
  query: null,
  pathname: '/:foo/bar',
  path: '/:foo/bar',
  href: 'http://[email protected]/:foo/bar' }

but is parsed incorrectly as of node v0.11.15:

➜  v0.12 git:(v0.11.14-release) ✗ ➜  git checkout v0.11.15-release
➜  v0.12 git:(v0.11.14-release) ✗ ./node --version
v0.11.15
➜  v0.12 git:(v0.11.15-release) ./node -p "require('url').parse('http://[email protected]:foo/bar')"
{ protocol: 'http:',
  slashes: true,
  auth: 'user',
  host: 'somehost.com:foo',
  port: null,
  hostname: 'somehost.com:foo',
  hash: null,
  search: null,
  query: null,
  pathname: '/bar',
  path: '/bar',
  href: 'http://[email protected]:foo/bar' }

The breaking change is 6120472 and has been partially reverted in io.js.

Among other things, it breaks npm dependencies that use git+ssh:

$ npm install git+ssh://[email protected]:npm/npm
npm ERR! git clone ssh://[email protected]:npm/npm Cloning into bare repository '/Users/JulienGilli/.npm/_git-remotes/ssh-git-github-com-npm-npm-712d6d60'...
npm ERR! git clone ssh://[email protected]:npm/npm ERROR: Repository not found.
npm ERR! git clone ssh://[email protected]:npm/npm fatal: Could not read from remote repository.
npm ERR! git clone ssh://[email protected]:npm/npm 
npm ERR! git clone ssh://[email protected]:npm/npm Please make sure you have the correct access rights
npm ERR! git clone ssh://[email protected]:npm/npm and the repository exists.
@misterdjules misterdjules added this to the 0.11.16 milestone Jan 21, 2015
@misterdjules misterdjules self-assigned this Jan 22, 2015
misterdjules pushed a commit to misterdjules/node that referenced this issue Jan 22, 2015
Fix regression introduced in c90eac7
that broke parsing of some ssh: urls.

An example url is ssh://[email protected]:npm/npm.git

Fixes nodejs#9072.

Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Julien Gilli <[email protected]>
misterdjules pushed a commit to misterdjules/node that referenced this issue Jan 23, 2015
Fix regression introduced in 6120472
that broke parsing of some ssh: urls.

An example url is ssh://[email protected]:npm/npm.git

Fixes nodejs#9072.

Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Julien Gilli <[email protected]>
Reviewed-By: Trevor Norris <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@misterdjules
Copy link
Author

Fixed by de5f24a.

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

No branches or pull requests

2 participants