Description
- Version: v7.0.0
- Platform: platform agnostic
- Subsystem: url.format
IMPACT: Before I get into the specifics, I want to be clear about what the impact is for npm
. It's actually pretty limited. As best as we can tell this only impacts when saving a file-type specifier to a package.json
with npm
, not when installing from one. As such, it can be worked around by editing the package.json
.
#7234 introduced a change to how url.format
printed invalid file:
type URLs. Specifically if someone gave it the invalid file:/absolute/path/to/file.txt
it would translate that into the valid file:///absolute/path/to/file.txt
. Previously invalid URLs were left unaltered.
npm
's use of file
URLs are usually to point at relative paths, which isn't something file
URLs are really setup to support. The way npm
does this is tack file:
on the front, so npm -i -S ./foo/
becomes file:foo
and npm -i -S ../foo
becomes file:../foo
.
As of v7, those become file://foo
and file://../foo
respectively. The first being a reference to /
on the foo
host, and the latter being a reference to /foo
on the ..
host.
Ok, so Node v7 is making legacy URLs "healthy" where it didn't used to and that bit our particular use case. We can update npm
to work around that, but there is an additional wrinkle…
We don't actually call url.format('file:foo')
. What we call is:
url.format({protocol: 'file', slashes: false, pathname: 'foo'})
It'd be legit to call this a doc bug and update there, imo, though ignoring properties in the object form feels odd to me. Either way, we'll be updating our code to not rely onurl.format
.