summaryrefslogtreecommitdiffstats
path: root/node_modules/path-browserify
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/path-browserify')
-rw-r--r--node_modules/path-browserify/LICENSE18
-rw-r--r--node_modules/path-browserify/index.js302
-rw-r--r--node_modules/path-browserify/package.json57
-rw-r--r--node_modules/path-browserify/readme.markdown3
-rw-r--r--node_modules/path-browserify/test/test-path.js424
5 files changed, 0 insertions, 804 deletions
diff --git a/node_modules/path-browserify/LICENSE b/node_modules/path-browserify/LICENSE
deleted file mode 100644
index ee27ba4..0000000
--- a/node_modules/path-browserify/LICENSE
+++ /dev/null
@@ -1,18 +0,0 @@
-This software is released under the MIT license:
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software is furnished to do so,
-subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/path-browserify/index.js b/node_modules/path-browserify/index.js
deleted file mode 100644
index 208658a..0000000
--- a/node_modules/path-browserify/index.js
+++ /dev/null
@@ -1,302 +0,0 @@
-// .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,
-// backported and transplited with Babel, with backwards-compat fixes
-
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-// USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-// resolves . and .. elements in a path array with directory names there
-// must be no slashes, empty elements, or device names (c:\) in the array
-// (so also no leading and trailing slashes - it does not distinguish
-// relative and absolute paths)
-function normalizeArray(parts, allowAboveRoot) {
- // if the path tries to go above the root, `up` ends up > 0
- var up = 0;
- for (var i = parts.length - 1; i >= 0; i--) {
- var last = parts[i];
- if (last === '.') {
- parts.splice(i, 1);
- } else if (last === '..') {
- parts.splice(i, 1);
- up++;
- } else if (up) {
- parts.splice(i, 1);
- up--;
- }
- }
-
- // if the path is allowed to go above the root, restore leading ..s
- if (allowAboveRoot) {
- for (; up--; up) {
- parts.unshift('..');
- }
- }
-
- return parts;
-}
-
-// path.resolve([from ...], to)
-// posix version
-exports.resolve = function() {
- var resolvedPath = '',
- resolvedAbsolute = false;
-
- for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
- var path = (i >= 0) ? arguments[i] : process.cwd();
-
- // Skip empty and invalid entries
- if (typeof path !== 'string') {
- throw new TypeError('Arguments to path.resolve must be strings');
- } else if (!path) {
- continue;
- }
-
- resolvedPath = path + '/' + resolvedPath;
- resolvedAbsolute = path.charAt(0) === '/';
- }
-
- // At this point the path should be resolved to a full absolute path, but
- // handle relative paths to be safe (might happen when process.cwd() fails)
-
- // Normalize the path
- resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
- return !!p;
- }), !resolvedAbsolute).join('/');
-
- return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
-};
-
-// path.normalize(path)
-// posix version
-exports.normalize = function(path) {
- var isAbsolute = exports.isAbsolute(path),
- trailingSlash = substr(path, -1) === '/';
-
- // Normalize the path
- path = normalizeArray(filter(path.split('/'), function(p) {
- return !!p;
- }), !isAbsolute).join('/');
-
- if (!path && !isAbsolute) {
- path = '.';
- }
- if (path && trailingSlash) {
- path += '/';
- }
-
- return (isAbsolute ? '/' : '') + path;
-};
-
-// posix version
-exports.isAbsolute = function(path) {
- return path.charAt(0) === '/';
-};
-
-// posix version
-exports.join = function() {
- var paths = Array.prototype.slice.call(arguments, 0);
- return exports.normalize(filter(paths, function(p, index) {
- if (typeof p !== 'string') {
- throw new TypeError('Arguments to path.join must be strings');
- }
- return p;
- }).join('/'));
-};
-
-
-// path.relative(from, to)
-// posix version
-exports.relative = function(from, to) {
- from = exports.resolve(from).substr(1);
- to = exports.resolve(to).substr(1);
-
- function trim(arr) {
- var start = 0;
- for (; start < arr.length; start++) {
- if (arr[start] !== '') break;
- }
-
- var end = arr.length - 1;
- for (; end >= 0; end--) {
- if (arr[end] !== '') break;
- }
-
- if (start > end) return [];
- return arr.slice(start, end - start + 1);
- }
-
- var fromParts = trim(from.split('/'));
- var toParts = trim(to.split('/'));
-
- var length = Math.min(fromParts.length, toParts.length);
- var samePartsLength = length;
- for (var i = 0; i < length; i++) {
- if (fromParts[i] !== toParts[i]) {
- samePartsLength = i;
- break;
- }
- }
-
- var outputParts = [];
- for (var i = samePartsLength; i < fromParts.length; i++) {
- outputParts.push('..');
- }
-
- outputParts = outputParts.concat(toParts.slice(samePartsLength));
-
- return outputParts.join('/');
-};
-
-exports.sep = '/';
-exports.delimiter = ':';
-
-exports.dirname = function (path) {
- if (typeof path !== 'string') path = path + '';
- if (path.length === 0) return '.';
- var code = path.charCodeAt(0);
- var hasRoot = code === 47 /*/*/;
- var end = -1;
- var matchedSlash = true;
- for (var i = path.length - 1; i >= 1; --i) {
- code = path.charCodeAt(i);
- if (code === 47 /*/*/) {
- if (!matchedSlash) {
- end = i;
- break;
- }
- } else {
- // We saw the first non-path separator
- matchedSlash = false;
- }
- }
-
- if (end === -1) return hasRoot ? '/' : '.';
- if (hasRoot && end === 1) {
- // return '//';
- // Backwards-compat fix:
- return '/';
- }
- return path.slice(0, end);
-};
-
-function basename(path) {
- if (typeof path !== 'string') path = path + '';
-
- var start = 0;
- var end = -1;
- var matchedSlash = true;
- var i;
-
- for (i = path.length - 1; i >= 0; --i) {
- if (path.charCodeAt(i) === 47 /*/*/) {
- // If we reached a path separator that was not part of a set of path
- // separators at the end of the string, stop now
- if (!matchedSlash) {
- start = i + 1;
- break;
- }
- } else if (end === -1) {
- // We saw the first non-path separator, mark this as the end of our
- // path component
- matchedSlash = false;
- end = i + 1;
- }
- }
-
- if (end === -1) return '';
- return path.slice(start, end);
-}
-
-// Uses a mixed approach for backwards-compatibility, as ext behavior changed
-// in new Node.js versions, so only basename() above is backported here
-exports.basename = function (path, ext) {
- var f = basename(path);
- if (ext && f.substr(-1 * ext.length) === ext) {
- f = f.substr(0, f.length - ext.length);
- }
- return f;
-};
-
-exports.extname = function (path) {
- if (typeof path !== 'string') path = path + '';
- var startDot = -1;
- var startPart = 0;
- var end = -1;
- var matchedSlash = true;
- // Track the state of characters (if any) we see before our first dot and
- // after any path separator we find
- var preDotState = 0;
- for (var i = path.length - 1; i >= 0; --i) {
- var code = path.charCodeAt(i);
- if (code === 47 /*/*/) {
- // If we reached a path separator that was not part of a set of path
- // separators at the end of the string, stop now
- if (!matchedSlash) {
- startPart = i + 1;
- break;
- }
- continue;
- }
- if (end === -1) {
- // We saw the first non-path separator, mark this as the end of our
- // extension
- matchedSlash = false;
- end = i + 1;
- }
- if (code === 46 /*.*/) {
- // If this is our first dot, mark it as the start of our extension
- if (startDot === -1)
- startDot = i;
- else if (preDotState !== 1)
- preDotState = 1;
- } else if (startDot !== -1) {
- // We saw a non-dot and non-path separator before our dot, so we should
- // have a good chance at having a non-empty extension
- preDotState = -1;
- }
- }
-
- if (startDot === -1 || end === -1 ||
- // We saw a non-dot character immediately before the dot
- preDotState === 0 ||
- // The (right-most) trimmed path component is exactly '..'
- preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
- return '';
- }
- return path.slice(startDot, end);
-};
-
-function filter (xs, f) {
- if (xs.filter) return xs.filter(f);
- var res = [];
- for (var i = 0; i < xs.length; i++) {
- if (f(xs[i], i, xs)) res.push(xs[i]);
- }
- return res;
-}
-
-// String.prototype.substr - negative index don't work in IE8
-var substr = 'ab'.substr(-1) === 'b'
- ? function (str, start, len) { return str.substr(start, len) }
- : function (str, start, len) {
- if (start < 0) start = str.length + start;
- return str.substr(start, len);
- }
-;
diff --git a/node_modules/path-browserify/package.json b/node_modules/path-browserify/package.json
deleted file mode 100644
index 07c81a3..0000000
--- a/node_modules/path-browserify/package.json
+++ /dev/null
@@ -1,57 +0,0 @@
-{
- "_from": "path-browserify@0.0.1",
- "_id": "path-browserify@0.0.1",
- "_inBundle": false,
- "_integrity": "sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ==",
- "_location": "/path-browserify",
- "_phantomChildren": {},
- "_requested": {
- "type": "version",
- "registry": true,
- "raw": "path-browserify@0.0.1",
- "name": "path-browserify",
- "escapedName": "path-browserify",
- "rawSpec": "0.0.1",
- "saveSpec": null,
- "fetchSpec": "0.0.1"
- },
- "_requiredBy": [
- "/node-libs-browser"
- ],
- "_resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz",
- "_shasum": "e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a",
- "_spec": "path-browserify@0.0.1",
- "_where": "/home/pruss/Dev/3-minute-website/node_modules/node-libs-browser",
- "author": {
- "name": "James Halliday",
- "email": "mail@substack.net",
- "url": "http://substack.net"
- },
- "bugs": {
- "url": "https://github.com/substack/path-browserify/issues"
- },
- "bundleDependencies": false,
- "dependencies": {},
- "deprecated": false,
- "description": "the path module from node core for browsers",
- "devDependencies": {
- "tape": "~1.0.4"
- },
- "homepage": "https://github.com/substack/path-browserify",
- "keywords": [
- "path",
- "browser",
- "browserify"
- ],
- "license": "MIT",
- "main": "index.js",
- "name": "path-browserify",
- "repository": {
- "type": "git",
- "url": "git://github.com/substack/path-browserify.git"
- },
- "scripts": {
- "test": "node test/test-path.js"
- },
- "version": "0.0.1"
-}
diff --git a/node_modules/path-browserify/readme.markdown b/node_modules/path-browserify/readme.markdown
deleted file mode 100644
index 8ae1dd8..0000000
--- a/node_modules/path-browserify/readme.markdown
+++ /dev/null
@@ -1,3 +0,0 @@
-# path-browserify
-
-the path module from node core for browsers
diff --git a/node_modules/path-browserify/test/test-path.js b/node_modules/path-browserify/test/test-path.js
deleted file mode 100644
index 29496e4..0000000
--- a/node_modules/path-browserify/test/test-path.js
+++ /dev/null
@@ -1,424 +0,0 @@
-// Copyright Joyent, Inc. and other Node contributors.
-//
-// Permission is hereby granted, free of charge, to any person obtaining a
-// copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to permit
-// persons to whom the Software is furnished to do so, subject to the
-// following conditions:
-//
-// The above copyright notice and this permission notice shall be included
-// in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
-// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-// USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-var assert = require('assert');
-
-var path = require('.');
-
-var isWindows = process.platform === 'win32';
-
-// Mock the node.js path
-var f = __dirname + '/simple/test-path.js';
-
-assert.equal(path.basename(f), 'test-path.js');
-assert.equal(path.basename(f, '.js'), 'test-path');
-assert.equal(path.basename(''), '');
-assert.equal(path.basename('/dir/basename.ext'), 'basename.ext');
-assert.equal(path.basename('/basename.ext'), 'basename.ext');
-assert.equal(path.basename('basename.ext'), 'basename.ext');
-assert.equal(path.basename('basename.ext/'), 'basename.ext');
-assert.equal(path.basename('basename.ext//'), 'basename.ext');
-
-if (isWindows) {
- // On Windows a backslash acts as a path separator.
- assert.equal(path.basename('\\dir\\basename.ext'), 'basename.ext');
- assert.equal(path.basename('\\basename.ext'), 'basename.ext');
- assert.equal(path.basename('basename.ext'), 'basename.ext');
- assert.equal(path.basename('basename.ext\\'), 'basename.ext');
- assert.equal(path.basename('basename.ext\\\\'), 'basename.ext');
-
-} else {
- // On unix a backslash is just treated as any other character.
- assert.equal(path.basename('\\dir\\basename.ext'), '\\dir\\basename.ext');
- assert.equal(path.basename('\\basename.ext'), '\\basename.ext');
- assert.equal(path.basename('basename.ext'), 'basename.ext');
- assert.equal(path.basename('basename.ext\\'), 'basename.ext\\');
- assert.equal(path.basename('basename.ext\\\\'), 'basename.ext\\\\');
-}
-
-// POSIX filenames may include control characters
-// c.f. http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html
-if (!isWindows) {
- var controlCharFilename = 'Icon' + String.fromCharCode(13);
- assert.equal(path.basename('/a/b/' + controlCharFilename),
- controlCharFilename);
-}
-
-assert.equal(path.extname(f), '.js');
-
-assert.equal(path.dirname(f).substr(-11),
- isWindows ? 'test\\simple' : 'test/simple');
-assert.equal(path.dirname('/a/b/'), '/a');
-assert.equal(path.dirname('/a/b'), '/a');
-assert.equal(path.dirname('/a'), '/');
-assert.equal(path.dirname(''), '.');
-assert.equal(path.dirname('/'), '/');
-assert.equal(path.dirname('////'), '/');
-
-if (isWindows) {
- assert.equal(path.dirname('c:\\'), 'c:\\');
- assert.equal(path.dirname('c:\\foo'), 'c:\\');
- assert.equal(path.dirname('c:\\foo\\'), 'c:\\');
- assert.equal(path.dirname('c:\\foo\\bar'), 'c:\\foo');
- assert.equal(path.dirname('c:\\foo\\bar\\'), 'c:\\foo');
- assert.equal(path.dirname('c:\\foo\\bar\\baz'), 'c:\\foo\\bar');
- assert.equal(path.dirname('\\'), '\\');
- assert.equal(path.dirname('\\foo'), '\\');
- assert.equal(path.dirname('\\foo\\'), '\\');
- assert.equal(path.dirname('\\foo\\bar'), '\\foo');
- assert.equal(path.dirname('\\foo\\bar\\'), '\\foo');
- assert.equal(path.dirname('\\foo\\bar\\baz'), '\\foo\\bar');
- assert.equal(path.dirname('c:'), 'c:');
- assert.equal(path.dirname('c:foo'), 'c:');
- assert.equal(path.dirname('c:foo\\'), 'c:');
- assert.equal(path.dirname('c:foo\\bar'), 'c:foo');
- assert.equal(path.dirname('c:foo\\bar\\'), 'c:foo');
- assert.equal(path.dirname('c:foo\\bar\\baz'), 'c:foo\\bar');
- assert.equal(path.dirname('\\\\unc\\share'), '\\\\unc\\share');
- assert.equal(path.dirname('\\\\unc\\share\\foo'), '\\\\unc\\share\\');
- assert.equal(path.dirname('\\\\unc\\share\\foo\\'), '\\\\unc\\share\\');
- assert.equal(path.dirname('\\\\unc\\share\\foo\\bar'),
- '\\\\unc\\share\\foo');
- assert.equal(path.dirname('\\\\unc\\share\\foo\\bar\\'),
- '\\\\unc\\share\\foo');
- assert.equal(path.dirname('\\\\unc\\share\\foo\\bar\\baz'),
- '\\\\unc\\share\\foo\\bar');
-}
-
-
-assert.equal(path.extname(''), '');
-assert.equal(path.extname('/path/to/file'), '');
-assert.equal(path.extname('/path/to/file.ext'), '.ext');
-assert.equal(path.extname('/path.to/file.ext'), '.ext');
-assert.equal(path.extname('/path.to/file'), '');
-assert.equal(path.extname('/path.to/.file'), '');
-assert.equal(path.extname('/path.to/.file.ext'), '.ext');
-assert.equal(path.extname('/path/to/f.ext'), '.ext');
-assert.equal(path.extname('/path/to/..ext'), '.ext');
-assert.equal(path.extname('file'), '');
-assert.equal(path.extname('file.ext'), '.ext');
-assert.equal(path.extname('.file'), '');
-assert.equal(path.extname('.file.ext'), '.ext');
-assert.equal(path.extname('/file'), '');
-assert.equal(path.extname('/file.ext'), '.ext');
-assert.equal(path.extname('/.file'), '');
-assert.equal(path.extname('/.file.ext'), '.ext');
-assert.equal(path.extname('.path/file.ext'), '.ext');
-assert.equal(path.extname('file.ext.ext'), '.ext');
-assert.equal(path.extname('file.'), '.');
-assert.equal(path.extname('.'), '');
-assert.equal(path.extname('./'), '');
-assert.equal(path.extname('.file.ext'), '.ext');
-assert.equal(path.extname('.file'), '');
-assert.equal(path.extname('.file.'), '.');
-assert.equal(path.extname('.file..'), '.');
-assert.equal(path.extname('..'), '');
-assert.equal(path.extname('../'), '');
-assert.equal(path.extname('..file.ext'), '.ext');
-assert.equal(path.extname('..file'), '.file');
-assert.equal(path.extname('..file.'), '.');
-assert.equal(path.extname('..file..'), '.');
-assert.equal(path.extname('...'), '.');
-assert.equal(path.extname('...ext'), '.ext');
-assert.equal(path.extname('....'), '.');
-assert.equal(path.extname('file.ext/'), '.ext');
-assert.equal(path.extname('file.ext//'), '.ext');
-assert.equal(path.extname('file/'), '');
-assert.equal(path.extname('file//'), '');
-assert.equal(path.extname('file./'), '.');
-assert.equal(path.extname('file.//'), '.');
-
-if (isWindows) {
- // On windows, backspace is a path separator.
- assert.equal(path.extname('.\\'), '');
- assert.equal(path.extname('..\\'), '');
- assert.equal(path.extname('file.ext\\'), '.ext');
- assert.equal(path.extname('file.ext\\\\'), '.ext');
- assert.equal(path.extname('file\\'), '');
- assert.equal(path.extname('file\\\\'), '');
- assert.equal(path.extname('file.\\'), '.');
- assert.equal(path.extname('file.\\\\'), '.');
-
-} else {
- // On unix, backspace is a valid name component like any other character.
- assert.equal(path.extname('.\\'), '');
- assert.equal(path.extname('..\\'), '.\\');
- assert.equal(path.extname('file.ext\\'), '.ext\\');
- assert.equal(path.extname('file.ext\\\\'), '.ext\\\\');
- assert.equal(path.extname('file\\'), '');
- assert.equal(path.extname('file\\\\'), '');
- assert.equal(path.extname('file.\\'), '.\\');
- assert.equal(path.extname('file.\\\\'), '.\\\\');
-}
-
-// path.join tests
-var failures = [];
-var joinTests =
- // arguments result
- [[['.', 'x/b', '..', '/b/c.js'], 'x/b/c.js'],
- [['/.', 'x/b', '..', '/b/c.js'], '/x/b/c.js'],
- [['/foo', '../../../bar'], '/bar'],
- [['foo', '../../../bar'], '../../bar'],
- [['foo/', '../../../bar'], '../../bar'],
- [['foo/x', '../../../bar'], '../bar'],
- [['foo/x', './bar'], 'foo/x/bar'],
- [['foo/x/', './bar'], 'foo/x/bar'],
- [['foo/x/', '.', 'bar'], 'foo/x/bar'],
- [['./'], './'],
- [['.', './'], './'],
- [['.', '.', '.'], '.'],
- [['.', './', '.'], '.'],
- [['.', '/./', '.'], '.'],
- [['.', '/////./', '.'], '.'],
- [['.'], '.'],
- [['', '.'], '.'],
- [['', 'foo'], 'foo'],
- [['foo', '/bar'], 'foo/bar'],
- [['', '/foo'], '/foo'],
- [['', '', '/foo'], '/foo'],
- [['', '', 'foo'], 'foo'],
- [['foo', ''], 'foo'],
- [['foo/', ''], 'foo/'],
- [['foo', '', '/bar'], 'foo/bar'],
- [['./', '..', '/foo'], '../foo'],
- [['./', '..', '..', '/foo'], '../../foo'],
- [['.', '..', '..', '/foo'], '../../foo'],
- [['', '..', '..', '/foo'], '../../foo'],
- [['/'], '/'],
- [['/', '.'], '/'],
- [['/', '..'], '/'],
- [['/', '..', '..'], '/'],
- [[''], '.'],
- [['', ''], '.'],
- [[' /foo'], ' /foo'],
- [[' ', 'foo'], ' /foo'],
- [[' ', '.'], ' '],
- [[' ', '/'], ' /'],
- [[' ', ''], ' '],
- [['/', 'foo'], '/foo'],
- [['/', '/foo'], '/foo'],
- [['/', '//foo'], '/foo'],
- [['/', '', '/foo'], '/foo'],
- [['', '/', 'foo'], '/foo'],
- [['', '/', '/foo'], '/foo']
- ];
-
-// Windows-specific join tests
-if (isWindows) {
- joinTests = joinTests.concat(
- [// UNC path expected
- [['//foo/bar'], '//foo/bar/'],
- [['\\/foo/bar'], '//foo/bar/'],
- [['\\\\foo/bar'], '//foo/bar/'],
- // UNC path expected - server and share separate
- [['//foo', 'bar'], '//foo/bar/'],
- [['//foo/', 'bar'], '//foo/bar/'],
- [['//foo', '/bar'], '//foo/bar/'],
- // UNC path expected - questionable
- [['//foo', '', 'bar'], '//foo/bar/'],
- [['//foo/', '', 'bar'], '//foo/bar/'],
- [['//foo/', '', '/bar'], '//foo/bar/'],
- // UNC path expected - even more questionable
- [['', '//foo', 'bar'], '//foo/bar/'],
- [['', '//foo/', 'bar'], '//foo/bar/'],
- [['', '//foo/', '/bar'], '//foo/bar/'],
- // No UNC path expected (no double slash in first component)
- [['\\', 'foo/bar'], '/foo/bar'],
- [['\\', '/foo/bar'], '/foo/bar'],
- [['', '/', '/foo/bar'], '/foo/bar'],
- // No UNC path expected (no non-slashes in first component - questionable)
- [['//', 'foo/bar'], '/foo/bar'],
- [['//', '/foo/bar'], '/foo/bar'],
- [['\\\\', '/', '/foo/bar'], '/foo/bar'],
- [['//'], '/'],
- // No UNC path expected (share name missing - questionable).
- [['//foo'], '/foo'],
- [['//foo/'], '/foo/'],
- [['//foo', '/'], '/foo/'],
- [['//foo', '', '/'], '/foo/'],
- // No UNC path expected (too many leading slashes - questionable)
- [['///foo/bar'], '/foo/bar'],
- [['////foo', 'bar'], '/foo/bar'],
- [['\\\\\\/foo/bar'], '/foo/bar'],
- // Drive-relative vs drive-absolute paths. This merely describes the
- // status quo, rather than being obviously right
- [['c:'], 'c:.'],
- [['c:.'], 'c:.'],
- [['c:', ''], 'c:.'],
- [['', 'c:'], 'c:.'],
- [['c:.', '/'], 'c:./'],
- [['c:.', 'file'], 'c:file'],
- [['c:', '/'], 'c:/'],
- [['c:', 'file'], 'c:/file']
- ]);
-}
-
-// Run the join tests.
-joinTests.forEach(function(test) {
- var actual = path.join.apply(path, test[0]);
- var expected = isWindows ? test[1].replace(/\//g, '\\') : test[1];
- var message = 'path.join(' + test[0].map(JSON.stringify).join(',') + ')' +
- '\n expect=' + JSON.stringify(expected) +
- '\n actual=' + JSON.stringify(actual);
- if (actual !== expected) failures.push('\n' + message);
- // assert.equal(actual, expected, message);
-});
-assert.equal(failures.length, 0, failures.join(''));
-var joinThrowTests = [true, false, 7, null, {}, undefined, [], NaN];
-joinThrowTests.forEach(function(test) {
- assert.throws(function() {
- path.join(test);
- }, TypeError);
- assert.throws(function() {
- path.resolve(test);
- }, TypeError);
-});
-
-
-// path normalize tests
-if (isWindows) {
- assert.equal(path.normalize('./fixtures///b/../b/c.js'),
- 'fixtures\\b\\c.js');
- assert.equal(path.normalize('/foo/../../../bar'), '\\bar');
- assert.equal(path.normalize('a//b//../b'), 'a\\b');
- assert.equal(path.normalize('a//b//./c'), 'a\\b\\c');
- assert.equal(path.normalize('a//b//.'), 'a\\b');
- assert.equal(path.normalize('//server/share/dir/file.ext'),
- '\\\\server\\share\\dir\\file.ext');
-} else {
- assert.equal(path.normalize('./fixtures///b/../b/c.js'),
- 'fixtures/b/c.js');
- assert.equal(path.normalize('/foo/../../../bar'), '/bar');
- assert.equal(path.normalize('a//b//../b'), 'a/b');
- assert.equal(path.normalize('a//b//./c'), 'a/b/c');
- assert.equal(path.normalize('a//b//.'), 'a/b');
-}
-
-// path.resolve tests
-if (isWindows) {
- // windows
- var resolveTests =
- // arguments result
- [[['c:/blah\\blah', 'd:/games', 'c:../a'], 'c:\\blah\\a'],
- [['c:/ignore', 'd:\\a/b\\c/d', '\\e.exe'], 'd:\\e.exe'],
- [['c:/ignore', 'c:/some/file'], 'c:\\some\\file'],
- [['d:/ignore', 'd:some/dir//'], 'd:\\ignore\\some\\dir'],
- [['.'], process.cwd()],
- [['//server/share', '..', 'relative\\'], '\\\\server\\share\\relative'],
- [['c:/', '//'], 'c:\\'],
- [['c:/', '//dir'], 'c:\\dir'],
- [['c:/', '//server/share'], '\\\\server\\share\\'],
- [['c:/', '//server//share'], '\\\\server\\share\\'],
- [['c:/', '///some//dir'], 'c:\\some\\dir']
- ];
-} else {
- // Posix
- var resolveTests =
- // arguments result
- [[['/var/lib', '../', 'file/'], '/var/file'],
- [['/var/lib', '/../', 'file/'], '/file'],
- [['a/b/c/', '../../..'], process.cwd()],
- [['.'], process.cwd()],
- [['/some/dir', '.', '/absolute/'], '/absolute']];
-}
-var failures = [];
-resolveTests.forEach(function(test) {
- var actual = path.resolve.apply(path, test[0]);
- var expected = test[1];
- var message = 'path.resolve(' + test[0].map(JSON.stringify).join(',') + ')' +
- '\n expect=' + JSON.stringify(expected) +
- '\n actual=' + JSON.stringify(actual);
- if (actual !== expected) failures.push('\n' + message);
- // assert.equal(actual, expected, message);
-});
-assert.equal(failures.length, 0, failures.join(''));
-
-// path.isAbsolute tests
-if (isWindows) {
- assert.equal(path.isAbsolute('//server/file'), true);
- assert.equal(path.isAbsolute('\\\\server\\file'), true);
- assert.equal(path.isAbsolute('C:/Users/'), true);
- assert.equal(path.isAbsolute('C:\\Users\\'), true);
- assert.equal(path.isAbsolute('C:cwd/another'), false);
- assert.equal(path.isAbsolute('C:cwd\\another'), false);
- assert.equal(path.isAbsolute('directory/directory'), false);
- assert.equal(path.isAbsolute('directory\\directory'), false);
-} else {
- assert.equal(path.isAbsolute('/home/foo'), true);
- assert.equal(path.isAbsolute('/home/foo/..'), true);
- assert.equal(path.isAbsolute('bar/'), false);
- assert.equal(path.isAbsolute('./baz'), false);
-}
-
-// path.relative tests
-if (isWindows) {
- // windows
- var relativeTests =
- // arguments result
- [['c:/blah\\blah', 'd:/games', 'd:\\games'],
- ['c:/aaaa/bbbb', 'c:/aaaa', '..'],
- ['c:/aaaa/bbbb', 'c:/cccc', '..\\..\\cccc'],
- ['c:/aaaa/bbbb', 'c:/aaaa/bbbb', ''],
- ['c:/aaaa/bbbb', 'c:/aaaa/cccc', '..\\cccc'],
- ['c:/aaaa/', 'c:/aaaa/cccc', 'cccc'],
- ['c:/', 'c:\\aaaa\\bbbb', 'aaaa\\bbbb'],
- ['c:/aaaa/bbbb', 'd:\\', 'd:\\']];
-} else {
- // posix
- var relativeTests =
- // arguments result
- [['/var/lib', '/var', '..'],
- ['/var/lib', '/bin', '../../bin'],
- ['/var/lib', '/var/lib', ''],
- ['/var/lib', '/var/apache', '../apache'],
- ['/var/', '/var/lib', 'lib'],
- ['/', '/var/lib', 'var/lib']];
-}
-var failures = [];
-relativeTests.forEach(function(test) {
- var actual = path.relative(test[0], test[1]);
- var expected = test[2];
- var message = 'path.relative(' +
- test.slice(0, 2).map(JSON.stringify).join(',') +
- ')' +
- '\n expect=' + JSON.stringify(expected) +
- '\n actual=' + JSON.stringify(actual);
- if (actual !== expected) failures.push('\n' + message);
-});
-assert.equal(failures.length, 0, failures.join(''));
-
-// path.sep tests
-if (isWindows) {
- // windows
- assert.equal(path.sep, '\\');
-} else {
- // posix
- assert.equal(path.sep, '/');
-}
-
-// path.delimiter tests
-if (isWindows) {
- // windows
- assert.equal(path.delimiter, ';');
-} else {
- // posix
- assert.equal(path.delimiter, ':');
-}