summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/tar/lib/strip-absolute-path.js
diff options
context:
space:
mode:
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.js14
1 files changed, 14 insertions, 0 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
new file mode 100644
index 0000000000..49161ddc30
--- /dev/null
+++ b/deps/npm/node_modules/tar/lib/strip-absolute-path.js
@@ -0,0 +1,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]
+}