GoScrobble/web/node_modules/tar/lib/strip-absolute-path.js

15 lines
427 B
JavaScript
Raw Permalink Normal View History

2022-04-25 02:47:15 +00:00
// unix absolute paths are also absolute on win32, so we use this for both
const { isAbsolute, parse } = require('path').win32
// returns [root, stripped]
module.exports = path => {
let r = ''
while (isAbsolute(path)) {
// windows will think that //x/y/z has a "root" of //x/y/
const root = path.charAt(0) === '/' ? '/' : parse(path).root
path = path.substr(root.length)
r += root
}
return [r, path]
}