diff options
author | npm team <ops+robot@npmjs.com> | 2021-08-19 20:47:33 +0300 |
---|---|---|
committer | Luigi Pinca <luigipinca@gmail.com> | 2021-08-20 15:53:49 +0300 |
commit | 248f4c376444d0202f1d08f039c59485d6aea2e9 (patch) | |
tree | 270bcf6dd5734fa43ea1603bfc4a066b6f8f7926 /deps/npm/node_modules/tar/lib/strip-absolute-path.js | |
parent | 279162cf98b22ec5d0afc182ea22c7a782ccd083 (diff) |
deps: upgrade npm to 7.21.0
PR-URL: https://github.com/nodejs/node/pull/39813
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'deps/npm/node_modules/tar/lib/strip-absolute-path.js')
-rw-r--r-- | deps/npm/node_modules/tar/lib/strip-absolute-path.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/deps/npm/node_modules/tar/lib/strip-absolute-path.js b/deps/npm/node_modules/tar/lib/strip-absolute-path.js index 49161ddc304..1aa2d2aec50 100644 --- a/deps/npm/node_modules/tar/lib/strip-absolute-path.js +++ b/deps/npm/node_modules/tar/lib/strip-absolute-path.js @@ -2,13 +2,23 @@ const { isAbsolute, parse } = require('path').win32 // returns [root, stripped] +// Note that windows will think that //x/y/z/a has a "root" of //x/y, and in +// those cases, we want to sanitize it to x/y/z/a, not z/a, so we strip / +// explicitly if it's the first character. +// drive-specific relative paths on Windows get their root stripped off even +// though they are not absolute, so `c:../foo` becomes ['c:', '../foo'] module.exports = path => { let r = '' - while (isAbsolute(path)) { + + let parsed = parse(path) + while (isAbsolute(path) || parsed.root) { // windows will think that //x/y/z has a "root" of //x/y/ - const root = path.charAt(0) === '/' ? '/' : parse(path).root + // but strip the //?/C:/ off of //?/C:/path + const root = path.charAt(0) === '/' && path.slice(0, 4) !== '//?/' ? '/' + : parsed.root path = path.substr(root.length) r += root + parsed = parse(path) } return [r, path] } |