mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-25 09:55:15 +00:00
15 lines
427 B
JavaScript
15 lines
427 B
JavaScript
// 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]
|
|
}
|