Don't put a / on resolved gitosis-style git urls

Fixes #3224
This commit is contained in:
isaacs
2013-06-06 14:14:26 -07:00
parent 90eb1e664c
commit 54e68d429e

View File

@@ -520,6 +520,15 @@ function archiveGitRemote (p, u, co, origUrl, cb) {
var parsed = url.parse(origUrl)
parsed.hash = stdout
resolved = url.format(parsed)
// https://github.com/isaacs/npm/issues/3224
// node incorrectly sticks a / at the start of the path
// We know that the host won't change, so split and detect this
var spo = origUrl.split(parsed.host)
var spr = resolved.split(parsed.host)
if (spo[1].charAt(0) === ':' && spr[1].charAt(0) === '/')
resolved = spr[0] + parsed.host + spr[1].slice(1)
log.verbose('resolved git url', resolved)
next()
})