Welcome to mirror list, hosted at ThFree Co, Russian Federation.

strip-absolute-path.js « lib « tar « node_modules « npm « deps - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 49161ddc30473c0dcf48dfe3dd5efd5ef15685de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// 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]
}