yeet
This commit is contained in:
12
node_modules/path-browserify/.github/FUNDING.yml
generated
vendored
Normal file
12
node_modules/path-browserify/.github/FUNDING.yml
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: npm/path-browserify
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
16
node_modules/path-browserify/.travis.yml
generated
vendored
Normal file
16
node_modules/path-browserify/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
language: node_js
|
||||
sudo: false
|
||||
node_js:
|
||||
- "10"
|
||||
- "9"
|
||||
- "8"
|
||||
- "6"
|
||||
- "4"
|
||||
- "iojs"
|
||||
- "0.12"
|
||||
- "0.10"
|
||||
- "0.8"
|
||||
before_install:
|
||||
# Old npm certs are untrusted https://github.com/npm/npm/issues/20191
|
||||
- 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.8" ]; then export NPM_CONFIG_STRICT_SSL=false; fi'
|
||||
- 'nvm install-latest-npm'
|
20
node_modules/path-browserify/CHANGELOG.md
generated
vendored
Normal file
20
node_modules/path-browserify/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
# path-browserify change log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## 1.0.1
|
||||
* Fix a duplicate test name.
|
||||
* Tweak LICENSE text so Github can recognise it.
|
||||
* Tweak LICENSE text to include the year and author.
|
||||
* Add security policy file.
|
||||
|
||||
## 1.0.0
|
||||
This release updates to the Node v10.3.0 API. **This change is breaking**,
|
||||
because path methods now throw errors when called with arguments that are not
|
||||
strings.
|
||||
|
||||
* Add `path.parse` and `path.format`.
|
||||
* Add `path.posix` as an alias to `path`.
|
||||
* Port tests from Node.js.
|
20
node_modules/path-browserify/LICENSE
generated
vendored
Normal file
20
node_modules/path-browserify/LICENSE
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013 James Halliday
|
||||
|
||||
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.
|
45
node_modules/path-browserify/README.md
generated
vendored
Normal file
45
node_modules/path-browserify/README.md
generated
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
# path-browserify [](https://travis-ci.org/browserify/path-browserify)
|
||||
|
||||
> The `path` module from Node.js for browsers
|
||||
|
||||
This implements the Node.js [`path`][path] module for environments that do not have it, like browsers.
|
||||
|
||||
> `path-browserify` currently matches the **Node.js 10.3** API.
|
||||
|
||||
## Install
|
||||
|
||||
You usually do not have to install `path-browserify` yourself! If your code runs in Node.js, `path` is built in. If your code runs in the browser, bundlers like [browserify](https://github.com/browserify/browserify) or [webpack](https://github.com/webpack/webpack) include the `path-browserify` module by default.
|
||||
|
||||
But if none of those apply, with npm do:
|
||||
|
||||
```
|
||||
npm install path-browserify
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var path = require('path')
|
||||
|
||||
var filename = 'logo.png';
|
||||
var logo = path.join('./assets/img', filename);
|
||||
document.querySelector('#logo').src = logo;
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
See the [Node.js path docs][path]. `path-browserify` currently matches the Node.js 10.3 API.
|
||||
`path-browserify` only implements the POSIX functions, not the win32 ones.
|
||||
|
||||
## Contributing
|
||||
|
||||
PRs are very welcome! The main way to contribute to `path-browserify` is by porting features, bugfixes and tests from Node.js. Ideally, code contributions to this module are copy-pasted from Node.js and transpiled to ES5, rather than reimplemented from scratch. Matching the Node.js code as closely as possible makes maintenance simpler when new changes land in Node.js.
|
||||
This module intends to provide exactly the same API as Node.js, so features that are not available in the core `path` module will not be accepted. Feature requests should instead be directed at [nodejs/node](https://github.com/nodejs/node) and will be added to this module once they are implemented in Node.js.
|
||||
|
||||
If there is a difference in behaviour between Node.js's `path` module and this module, please open an issue!
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE)
|
||||
|
||||
[path]: https://nodejs.org/docs/v10.3.0/api/path.html
|
529
node_modules/path-browserify/index.js
generated
vendored
Normal file
529
node_modules/path-browserify/index.js
generated
vendored
Normal file
@ -0,0 +1,529 @@
|
||||
// 'path' module extracted from Node.js v8.11.1 (only the posix part)
|
||||
// transplited with Babel
|
||||
|
||||
// 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.
|
||||
|
||||
'use strict';
|
||||
|
||||
function assertPath(path) {
|
||||
if (typeof path !== 'string') {
|
||||
throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));
|
||||
}
|
||||
}
|
||||
|
||||
// Resolves . and .. elements in a path with directory names
|
||||
function normalizeStringPosix(path, allowAboveRoot) {
|
||||
var res = '';
|
||||
var lastSegmentLength = 0;
|
||||
var lastSlash = -1;
|
||||
var dots = 0;
|
||||
var code;
|
||||
for (var i = 0; i <= path.length; ++i) {
|
||||
if (i < path.length)
|
||||
code = path.charCodeAt(i);
|
||||
else if (code === 47 /*/*/)
|
||||
break;
|
||||
else
|
||||
code = 47 /*/*/;
|
||||
if (code === 47 /*/*/) {
|
||||
if (lastSlash === i - 1 || dots === 1) {
|
||||
// NOOP
|
||||
} else if (lastSlash !== i - 1 && dots === 2) {
|
||||
if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) {
|
||||
if (res.length > 2) {
|
||||
var lastSlashIndex = res.lastIndexOf('/');
|
||||
if (lastSlashIndex !== res.length - 1) {
|
||||
if (lastSlashIndex === -1) {
|
||||
res = '';
|
||||
lastSegmentLength = 0;
|
||||
} else {
|
||||
res = res.slice(0, lastSlashIndex);
|
||||
lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
|
||||
}
|
||||
lastSlash = i;
|
||||
dots = 0;
|
||||
continue;
|
||||
}
|
||||
} else if (res.length === 2 || res.length === 1) {
|
||||
res = '';
|
||||
lastSegmentLength = 0;
|
||||
lastSlash = i;
|
||||
dots = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (allowAboveRoot) {
|
||||
if (res.length > 0)
|
||||
res += '/..';
|
||||
else
|
||||
res = '..';
|
||||
lastSegmentLength = 2;
|
||||
}
|
||||
} else {
|
||||
if (res.length > 0)
|
||||
res += '/' + path.slice(lastSlash + 1, i);
|
||||
else
|
||||
res = path.slice(lastSlash + 1, i);
|
||||
lastSegmentLength = i - lastSlash - 1;
|
||||
}
|
||||
lastSlash = i;
|
||||
dots = 0;
|
||||
} else if (code === 46 /*.*/ && dots !== -1) {
|
||||
++dots;
|
||||
} else {
|
||||
dots = -1;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
function _format(sep, pathObject) {
|
||||
var dir = pathObject.dir || pathObject.root;
|
||||
var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');
|
||||
if (!dir) {
|
||||
return base;
|
||||
}
|
||||
if (dir === pathObject.root) {
|
||||
return dir + base;
|
||||
}
|
||||
return dir + sep + base;
|
||||
}
|
||||
|
||||
var posix = {
|
||||
// path.resolve([from ...], to)
|
||||
resolve: function resolve() {
|
||||
var resolvedPath = '';
|
||||
var resolvedAbsolute = false;
|
||||
var cwd;
|
||||
|
||||
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
||||
var path;
|
||||
if (i >= 0)
|
||||
path = arguments[i];
|
||||
else {
|
||||
if (cwd === undefined)
|
||||
cwd = process.cwd();
|
||||
path = cwd;
|
||||
}
|
||||
|
||||
assertPath(path);
|
||||
|
||||
// Skip empty entries
|
||||
if (path.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
resolvedPath = path + '/' + resolvedPath;
|
||||
resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;
|
||||
}
|
||||
|
||||
// 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 = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
|
||||
|
||||
if (resolvedAbsolute) {
|
||||
if (resolvedPath.length > 0)
|
||||
return '/' + resolvedPath;
|
||||
else
|
||||
return '/';
|
||||
} else if (resolvedPath.length > 0) {
|
||||
return resolvedPath;
|
||||
} else {
|
||||
return '.';
|
||||
}
|
||||
},
|
||||
|
||||
normalize: function normalize(path) {
|
||||
assertPath(path);
|
||||
|
||||
if (path.length === 0) return '.';
|
||||
|
||||
var isAbsolute = path.charCodeAt(0) === 47 /*/*/;
|
||||
var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/;
|
||||
|
||||
// Normalize the path
|
||||
path = normalizeStringPosix(path, !isAbsolute);
|
||||
|
||||
if (path.length === 0 && !isAbsolute) path = '.';
|
||||
if (path.length > 0 && trailingSeparator) path += '/';
|
||||
|
||||
if (isAbsolute) return '/' + path;
|
||||
return path;
|
||||
},
|
||||
|
||||
isAbsolute: function isAbsolute(path) {
|
||||
assertPath(path);
|
||||
return path.length > 0 && path.charCodeAt(0) === 47 /*/*/;
|
||||
},
|
||||
|
||||
join: function join() {
|
||||
if (arguments.length === 0)
|
||||
return '.';
|
||||
var joined;
|
||||
for (var i = 0; i < arguments.length; ++i) {
|
||||
var arg = arguments[i];
|
||||
assertPath(arg);
|
||||
if (arg.length > 0) {
|
||||
if (joined === undefined)
|
||||
joined = arg;
|
||||
else
|
||||
joined += '/' + arg;
|
||||
}
|
||||
}
|
||||
if (joined === undefined)
|
||||
return '.';
|
||||
return posix.normalize(joined);
|
||||
},
|
||||
|
||||
relative: function relative(from, to) {
|
||||
assertPath(from);
|
||||
assertPath(to);
|
||||
|
||||
if (from === to) return '';
|
||||
|
||||
from = posix.resolve(from);
|
||||
to = posix.resolve(to);
|
||||
|
||||
if (from === to) return '';
|
||||
|
||||
// Trim any leading backslashes
|
||||
var fromStart = 1;
|
||||
for (; fromStart < from.length; ++fromStart) {
|
||||
if (from.charCodeAt(fromStart) !== 47 /*/*/)
|
||||
break;
|
||||
}
|
||||
var fromEnd = from.length;
|
||||
var fromLen = fromEnd - fromStart;
|
||||
|
||||
// Trim any leading backslashes
|
||||
var toStart = 1;
|
||||
for (; toStart < to.length; ++toStart) {
|
||||
if (to.charCodeAt(toStart) !== 47 /*/*/)
|
||||
break;
|
||||
}
|
||||
var toEnd = to.length;
|
||||
var toLen = toEnd - toStart;
|
||||
|
||||
// Compare paths to find the longest common path from root
|
||||
var length = fromLen < toLen ? fromLen : toLen;
|
||||
var lastCommonSep = -1;
|
||||
var i = 0;
|
||||
for (; i <= length; ++i) {
|
||||
if (i === length) {
|
||||
if (toLen > length) {
|
||||
if (to.charCodeAt(toStart + i) === 47 /*/*/) {
|
||||
// We get here if `from` is the exact base path for `to`.
|
||||
// For example: from='/foo/bar'; to='/foo/bar/baz'
|
||||
return to.slice(toStart + i + 1);
|
||||
} else if (i === 0) {
|
||||
// We get here if `from` is the root
|
||||
// For example: from='/'; to='/foo'
|
||||
return to.slice(toStart + i);
|
||||
}
|
||||
} else if (fromLen > length) {
|
||||
if (from.charCodeAt(fromStart + i) === 47 /*/*/) {
|
||||
// We get here if `to` is the exact base path for `from`.
|
||||
// For example: from='/foo/bar/baz'; to='/foo/bar'
|
||||
lastCommonSep = i;
|
||||
} else if (i === 0) {
|
||||
// We get here if `to` is the root.
|
||||
// For example: from='/foo'; to='/'
|
||||
lastCommonSep = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
var fromCode = from.charCodeAt(fromStart + i);
|
||||
var toCode = to.charCodeAt(toStart + i);
|
||||
if (fromCode !== toCode)
|
||||
break;
|
||||
else if (fromCode === 47 /*/*/)
|
||||
lastCommonSep = i;
|
||||
}
|
||||
|
||||
var out = '';
|
||||
// Generate the relative path based on the path difference between `to`
|
||||
// and `from`
|
||||
for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
|
||||
if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {
|
||||
if (out.length === 0)
|
||||
out += '..';
|
||||
else
|
||||
out += '/..';
|
||||
}
|
||||
}
|
||||
|
||||
// Lastly, append the rest of the destination (`to`) path that comes after
|
||||
// the common path parts
|
||||
if (out.length > 0)
|
||||
return out + to.slice(toStart + lastCommonSep);
|
||||
else {
|
||||
toStart += lastCommonSep;
|
||||
if (to.charCodeAt(toStart) === 47 /*/*/)
|
||||
++toStart;
|
||||
return to.slice(toStart);
|
||||
}
|
||||
},
|
||||
|
||||
_makeLong: function _makeLong(path) {
|
||||
return path;
|
||||
},
|
||||
|
||||
dirname: function dirname(path) {
|
||||
assertPath(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 '//';
|
||||
return path.slice(0, end);
|
||||
},
|
||||
|
||||
basename: function basename(path, ext) {
|
||||
if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string');
|
||||
assertPath(path);
|
||||
|
||||
var start = 0;
|
||||
var end = -1;
|
||||
var matchedSlash = true;
|
||||
var i;
|
||||
|
||||
if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
|
||||
if (ext.length === path.length && ext === path) return '';
|
||||
var extIdx = ext.length - 1;
|
||||
var firstNonSlashEnd = -1;
|
||||
for (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) {
|
||||
start = i + 1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (firstNonSlashEnd === -1) {
|
||||
// We saw the first non-path separator, remember this index in case
|
||||
// we need it if the extension ends up not matching
|
||||
matchedSlash = false;
|
||||
firstNonSlashEnd = i + 1;
|
||||
}
|
||||
if (extIdx >= 0) {
|
||||
// Try to match the explicit extension
|
||||
if (code === ext.charCodeAt(extIdx)) {
|
||||
if (--extIdx === -1) {
|
||||
// We matched the extension, so mark this as the end of our path
|
||||
// component
|
||||
end = i;
|
||||
}
|
||||
} else {
|
||||
// Extension does not match, so our result is the entire path
|
||||
// component
|
||||
extIdx = -1;
|
||||
end = firstNonSlashEnd;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;
|
||||
return path.slice(start, end);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
},
|
||||
|
||||
extname: function extname(path) {
|
||||
assertPath(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);
|
||||
},
|
||||
|
||||
format: function format(pathObject) {
|
||||
if (pathObject === null || typeof pathObject !== 'object') {
|
||||
throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
|
||||
}
|
||||
return _format('/', pathObject);
|
||||
},
|
||||
|
||||
parse: function parse(path) {
|
||||
assertPath(path);
|
||||
|
||||
var ret = { root: '', dir: '', base: '', ext: '', name: '' };
|
||||
if (path.length === 0) return ret;
|
||||
var code = path.charCodeAt(0);
|
||||
var isAbsolute = code === 47 /*/*/;
|
||||
var start;
|
||||
if (isAbsolute) {
|
||||
ret.root = '/';
|
||||
start = 1;
|
||||
} else {
|
||||
start = 0;
|
||||
}
|
||||
var startDot = -1;
|
||||
var startPart = 0;
|
||||
var end = -1;
|
||||
var matchedSlash = true;
|
||||
var i = path.length - 1;
|
||||
|
||||
// Track the state of characters (if any) we see before our first dot and
|
||||
// after any path separator we find
|
||||
var preDotState = 0;
|
||||
|
||||
// Get non-dir info
|
||||
for (; i >= start; --i) {
|
||||
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) {
|
||||
if (end !== -1) {
|
||||
if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);
|
||||
}
|
||||
} else {
|
||||
if (startPart === 0 && isAbsolute) {
|
||||
ret.name = path.slice(1, startDot);
|
||||
ret.base = path.slice(1, end);
|
||||
} else {
|
||||
ret.name = path.slice(startPart, startDot);
|
||||
ret.base = path.slice(startPart, end);
|
||||
}
|
||||
ret.ext = path.slice(startDot, end);
|
||||
}
|
||||
|
||||
if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/';
|
||||
|
||||
return ret;
|
||||
},
|
||||
|
||||
sep: '/',
|
||||
delimiter: ':',
|
||||
win32: null,
|
||||
posix: null
|
||||
};
|
||||
|
||||
posix.posix = posix;
|
||||
|
||||
module.exports = posix;
|
30
node_modules/path-browserify/package.json
generated
vendored
Normal file
30
node_modules/path-browserify/package.json
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "path-browserify",
|
||||
"description": "the path module from node core for browsers",
|
||||
"version": "1.0.1",
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"bugs": "https://github.com/browserify/path-browserify/issues",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"tape": "^4.9.0"
|
||||
},
|
||||
"homepage": "https://github.com/browserify/path-browserify",
|
||||
"keywords": [
|
||||
"browser",
|
||||
"browserify",
|
||||
"path"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/browserify/path-browserify.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test"
|
||||
}
|
||||
}
|
10
node_modules/path-browserify/security.md
generated
vendored
Normal file
10
node_modules/path-browserify/security.md
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
Only the latest major version is supported at any given time.
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
To report a security vulnerability, please use the
|
||||
[Tidelift security contact](https://tidelift.com/security).
|
||||
Tidelift will coordinate the fix and disclosure.
|
9
node_modules/path-browserify/test/index.js
generated
vendored
Normal file
9
node_modules/path-browserify/test/index.js
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
require('./test-path');
|
||||
require('./test-path-basename');
|
||||
require('./test-path-dirname');
|
||||
require('./test-path-extname');
|
||||
require('./test-path-isabsolute');
|
||||
require('./test-path-join');
|
||||
require('./test-path-relative');
|
||||
require('./test-path-resolve');
|
||||
require('./test-path-zero-length-strings');
|
79
node_modules/path-browserify/test/test-path-basename.js
generated
vendored
Normal file
79
node_modules/path-browserify/test/test-path-basename.js
generated
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
'use strict';
|
||||
var tape = require('tape');
|
||||
var path = require('../');
|
||||
|
||||
tape('path.basename', function (t) {
|
||||
t.strictEqual(path.basename(__filename), 'test-path-basename.js');
|
||||
t.strictEqual(path.basename(__filename, '.js'), 'test-path-basename');
|
||||
t.strictEqual(path.basename('.js', '.js'), '');
|
||||
t.strictEqual(path.basename(''), '');
|
||||
t.strictEqual(path.basename('/dir/basename.ext'), 'basename.ext');
|
||||
t.strictEqual(path.basename('/basename.ext'), 'basename.ext');
|
||||
t.strictEqual(path.basename('basename.ext'), 'basename.ext');
|
||||
t.strictEqual(path.basename('basename.ext/'), 'basename.ext');
|
||||
t.strictEqual(path.basename('basename.ext//'), 'basename.ext');
|
||||
t.strictEqual(path.basename('aaa/bbb', '/bbb'), 'bbb');
|
||||
t.strictEqual(path.basename('aaa/bbb', 'a/bbb'), 'bbb');
|
||||
t.strictEqual(path.basename('aaa/bbb', 'bbb'), 'bbb');
|
||||
t.strictEqual(path.basename('aaa/bbb//', 'bbb'), 'bbb');
|
||||
t.strictEqual(path.basename('aaa/bbb', 'bb'), 'b');
|
||||
t.strictEqual(path.basename('aaa/bbb', 'b'), 'bb');
|
||||
t.strictEqual(path.basename('/aaa/bbb', '/bbb'), 'bbb');
|
||||
t.strictEqual(path.basename('/aaa/bbb', 'a/bbb'), 'bbb');
|
||||
t.strictEqual(path.basename('/aaa/bbb', 'bbb'), 'bbb');
|
||||
t.strictEqual(path.basename('/aaa/bbb//', 'bbb'), 'bbb');
|
||||
t.strictEqual(path.basename('/aaa/bbb', 'bb'), 'b');
|
||||
t.strictEqual(path.basename('/aaa/bbb', 'b'), 'bb');
|
||||
t.strictEqual(path.basename('/aaa/bbb'), 'bbb');
|
||||
t.strictEqual(path.basename('/aaa/'), 'aaa');
|
||||
t.strictEqual(path.basename('/aaa/b'), 'b');
|
||||
t.strictEqual(path.basename('/a/b'), 'b');
|
||||
t.strictEqual(path.basename('//a'), 'a');
|
||||
t.end();
|
||||
})
|
||||
|
||||
tape('path.win32.basename', { skip: true }, function (t) {
|
||||
// On Windows a backslash acts as a path separator.
|
||||
t.strictEqual(path.win32.basename('\\dir\\basename.ext'), 'basename.ext');
|
||||
t.strictEqual(path.win32.basename('\\basename.ext'), 'basename.ext');
|
||||
t.strictEqual(path.win32.basename('basename.ext'), 'basename.ext');
|
||||
t.strictEqual(path.win32.basename('basename.ext\\'), 'basename.ext');
|
||||
t.strictEqual(path.win32.basename('basename.ext\\\\'), 'basename.ext');
|
||||
t.strictEqual(path.win32.basename('foo'), 'foo');
|
||||
t.strictEqual(path.win32.basename('aaa\\bbb', '\\bbb'), 'bbb');
|
||||
t.strictEqual(path.win32.basename('aaa\\bbb', 'a\\bbb'), 'bbb');
|
||||
t.strictEqual(path.win32.basename('aaa\\bbb', 'bbb'), 'bbb');
|
||||
t.strictEqual(path.win32.basename('aaa\\bbb\\\\\\\\', 'bbb'), 'bbb');
|
||||
t.strictEqual(path.win32.basename('aaa\\bbb', 'bb'), 'b');
|
||||
t.strictEqual(path.win32.basename('aaa\\bbb', 'b'), 'bb');
|
||||
t.strictEqual(path.win32.basename('C:'), '');
|
||||
t.strictEqual(path.win32.basename('C:.'), '.');
|
||||
t.strictEqual(path.win32.basename('C:\\'), '');
|
||||
t.strictEqual(path.win32.basename('C:\\dir\\base.ext'), 'base.ext');
|
||||
t.strictEqual(path.win32.basename('C:\\basename.ext'), 'basename.ext');
|
||||
t.strictEqual(path.win32.basename('C:basename.ext'), 'basename.ext');
|
||||
t.strictEqual(path.win32.basename('C:basename.ext\\'), 'basename.ext');
|
||||
t.strictEqual(path.win32.basename('C:basename.ext\\\\'), 'basename.ext');
|
||||
t.strictEqual(path.win32.basename('C:foo'), 'foo');
|
||||
t.strictEqual(path.win32.basename('file:stream'), 'file:stream');
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('On unix a backslash is just treated as any other character.', function (t) {
|
||||
t.strictEqual(path.posix.basename('\\dir\\basename.ext'),
|
||||
'\\dir\\basename.ext');
|
||||
t.strictEqual(path.posix.basename('\\basename.ext'), '\\basename.ext');
|
||||
t.strictEqual(path.posix.basename('basename.ext'), 'basename.ext');
|
||||
t.strictEqual(path.posix.basename('basename.ext\\'), 'basename.ext\\');
|
||||
t.strictEqual(path.posix.basename('basename.ext\\\\'), 'basename.ext\\\\');
|
||||
t.strictEqual(path.posix.basename('foo'), 'foo');
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('POSIX filenames may include control characters', function (t) {
|
||||
// c.f. http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html
|
||||
var controlCharFilename = "Icon" + (String.fromCharCode(13));
|
||||
t.strictEqual(path.posix.basename(("/a/b/" + controlCharFilename)),
|
||||
controlCharFilename);
|
||||
t.end();
|
||||
});
|
58
node_modules/path-browserify/test/test-path-dirname.js
generated
vendored
Normal file
58
node_modules/path-browserify/test/test-path-dirname.js
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
var tape = require('tape');
|
||||
var path = require('../');
|
||||
|
||||
tape('path.posix.dirname', function (t) {
|
||||
t.strictEqual(path.posix.dirname('/a/b/'), '/a');
|
||||
t.strictEqual(path.posix.dirname('/a/b'), '/a');
|
||||
t.strictEqual(path.posix.dirname('/a'), '/');
|
||||
t.strictEqual(path.posix.dirname(''), '.');
|
||||
t.strictEqual(path.posix.dirname('/'), '/');
|
||||
t.strictEqual(path.posix.dirname('////'), '/');
|
||||
t.strictEqual(path.posix.dirname('//a'), '//');
|
||||
t.strictEqual(path.posix.dirname('foo'), '.');
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('path.win32.dirname', { skip: true }, function (t) {
|
||||
t.strictEqual(path.win32.dirname('c:\\'), 'c:\\');
|
||||
t.strictEqual(path.win32.dirname('c:\\foo'), 'c:\\');
|
||||
t.strictEqual(path.win32.dirname('c:\\foo\\'), 'c:\\');
|
||||
t.strictEqual(path.win32.dirname('c:\\foo\\bar'), 'c:\\foo');
|
||||
t.strictEqual(path.win32.dirname('c:\\foo\\bar\\'), 'c:\\foo');
|
||||
t.strictEqual(path.win32.dirname('c:\\foo\\bar\\baz'), 'c:\\foo\\bar');
|
||||
t.strictEqual(path.win32.dirname('\\'), '\\');
|
||||
t.strictEqual(path.win32.dirname('\\foo'), '\\');
|
||||
t.strictEqual(path.win32.dirname('\\foo\\'), '\\');
|
||||
t.strictEqual(path.win32.dirname('\\foo\\bar'), '\\foo');
|
||||
t.strictEqual(path.win32.dirname('\\foo\\bar\\'), '\\foo');
|
||||
t.strictEqual(path.win32.dirname('\\foo\\bar\\baz'), '\\foo\\bar');
|
||||
t.strictEqual(path.win32.dirname('c:'), 'c:');
|
||||
t.strictEqual(path.win32.dirname('c:foo'), 'c:');
|
||||
t.strictEqual(path.win32.dirname('c:foo\\'), 'c:');
|
||||
t.strictEqual(path.win32.dirname('c:foo\\bar'), 'c:foo');
|
||||
t.strictEqual(path.win32.dirname('c:foo\\bar\\'), 'c:foo');
|
||||
t.strictEqual(path.win32.dirname('c:foo\\bar\\baz'), 'c:foo\\bar');
|
||||
t.strictEqual(path.win32.dirname('file:stream'), '.');
|
||||
t.strictEqual(path.win32.dirname('dir\\file:stream'), 'dir');
|
||||
t.strictEqual(path.win32.dirname('\\\\unc\\share'),
|
||||
'\\\\unc\\share');
|
||||
t.strictEqual(path.win32.dirname('\\\\unc\\share\\foo'),
|
||||
'\\\\unc\\share\\');
|
||||
t.strictEqual(path.win32.dirname('\\\\unc\\share\\foo\\'),
|
||||
'\\\\unc\\share\\');
|
||||
t.strictEqual(path.win32.dirname('\\\\unc\\share\\foo\\bar'),
|
||||
'\\\\unc\\share\\foo');
|
||||
t.strictEqual(path.win32.dirname('\\\\unc\\share\\foo\\bar\\'),
|
||||
'\\\\unc\\share\\foo');
|
||||
t.strictEqual(path.win32.dirname('\\\\unc\\share\\foo\\bar\\baz'),
|
||||
'\\\\unc\\share\\foo\\bar');
|
||||
t.strictEqual(path.win32.dirname('/a/b/'), '/a');
|
||||
t.strictEqual(path.win32.dirname('/a/b'), '/a');
|
||||
t.strictEqual(path.win32.dirname('/a'), '/');
|
||||
t.strictEqual(path.win32.dirname(''), '.');
|
||||
t.strictEqual(path.win32.dirname('/'), '/');
|
||||
t.strictEqual(path.win32.dirname('////'), '/');
|
||||
t.strictEqual(path.win32.dirname('foo'), '.');
|
||||
t.end();
|
||||
});
|
96
node_modules/path-browserify/test/test-path-extname.js
generated
vendored
Normal file
96
node_modules/path-browserify/test/test-path-extname.js
generated
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
'use strict';
|
||||
var tape = require('tape');
|
||||
var path = require('../');
|
||||
|
||||
var slashRE = /\//g;
|
||||
|
||||
var pairs = [
|
||||
[__filename, '.js'],
|
||||
['', ''],
|
||||
['/path/to/file', ''],
|
||||
['/path/to/file.ext', '.ext'],
|
||||
['/path.to/file.ext', '.ext'],
|
||||
['/path.to/file', ''],
|
||||
['/path.to/.file', ''],
|
||||
['/path.to/.file.ext', '.ext'],
|
||||
['/path/to/f.ext', '.ext'],
|
||||
['/path/to/..ext', '.ext'],
|
||||
['/path/to/..', ''],
|
||||
['file', ''],
|
||||
['file.ext', '.ext'],
|
||||
['.file', ''],
|
||||
['.file.ext', '.ext'],
|
||||
['/file', ''],
|
||||
['/file.ext', '.ext'],
|
||||
['/.file', ''],
|
||||
['/.file.ext', '.ext'],
|
||||
['.path/file.ext', '.ext'],
|
||||
['file.ext.ext', '.ext'],
|
||||
['file.', '.'],
|
||||
['.', ''],
|
||||
['./', ''],
|
||||
['.file.ext', '.ext'],
|
||||
['.file', ''],
|
||||
['.file.', '.'],
|
||||
['.file..', '.'],
|
||||
['..', ''],
|
||||
['../', ''],
|
||||
['..file.ext', '.ext'],
|
||||
['..file', '.file'],
|
||||
['..file.', '.'],
|
||||
['..file..', '.'],
|
||||
['...', '.'],
|
||||
['...ext', '.ext'],
|
||||
['....', '.'],
|
||||
['file.ext/', '.ext'],
|
||||
['file.ext//', '.ext'],
|
||||
['file/', ''],
|
||||
['file//', ''],
|
||||
['file./', '.'],
|
||||
['file.//', '.'] ];
|
||||
|
||||
tape('path.posix.extname', function (t) {
|
||||
pairs.forEach(function (p) {
|
||||
var input = p[0];
|
||||
var expected = p[1];
|
||||
t.strictEqual(expected, path.posix.extname(input));
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('path.win32.extname', { skip: true }, function (t) {
|
||||
pairs.forEach(function (p) {
|
||||
var input = p[0].replace(slashRE, '\\');
|
||||
var expected = p[1];
|
||||
t.strictEqual(expected, path.win32.extname(input));
|
||||
t.strictEqual(expected, path.win32.extname("C:" + input));
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('path.win32.extname backslash', { skip: true }, function (t) {
|
||||
// On Windows, backslash is a path separator.
|
||||
t.strictEqual(path.win32.extname('.\\'), '');
|
||||
t.strictEqual(path.win32.extname('..\\'), '');
|
||||
t.strictEqual(path.win32.extname('file.ext\\'), '.ext');
|
||||
t.strictEqual(path.win32.extname('file.ext\\\\'), '.ext');
|
||||
t.strictEqual(path.win32.extname('file\\'), '');
|
||||
t.strictEqual(path.win32.extname('file\\\\'), '');
|
||||
t.strictEqual(path.win32.extname('file.\\'), '.');
|
||||
t.strictEqual(path.win32.extname('file.\\\\'), '.');
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('path.posix.extname backslash', function (t) {
|
||||
// On *nix, backslash is a valid name component like any other character.
|
||||
t.strictEqual(path.posix.extname('.\\'), '');
|
||||
t.strictEqual(path.posix.extname('..\\'), '.\\');
|
||||
t.strictEqual(path.posix.extname('file.ext\\'), '.ext\\');
|
||||
t.strictEqual(path.posix.extname('file.ext\\\\'), '.ext\\\\');
|
||||
t.strictEqual(path.posix.extname('file\\'), '');
|
||||
t.strictEqual(path.posix.extname('file\\\\'), '');
|
||||
t.strictEqual(path.posix.extname('file.\\'), '.\\');
|
||||
t.strictEqual(path.posix.extname('file.\\\\'), '.\\\\');
|
||||
t.end();
|
||||
});
|
||||
|
33
node_modules/path-browserify/test/test-path-isabsolute.js
generated
vendored
Normal file
33
node_modules/path-browserify/test/test-path-isabsolute.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
var tape = require('tape');
|
||||
var path = require('../');
|
||||
|
||||
tape('path.win32.isAbsolute', { skip: true }, function (t) {
|
||||
t.strictEqual(path.win32.isAbsolute('/'), true);
|
||||
t.strictEqual(path.win32.isAbsolute('//'), true);
|
||||
t.strictEqual(path.win32.isAbsolute('//server'), true);
|
||||
t.strictEqual(path.win32.isAbsolute('//server/file'), true);
|
||||
t.strictEqual(path.win32.isAbsolute('\\\\server\\file'), true);
|
||||
t.strictEqual(path.win32.isAbsolute('\\\\server'), true);
|
||||
t.strictEqual(path.win32.isAbsolute('\\\\'), true);
|
||||
t.strictEqual(path.win32.isAbsolute('c'), false);
|
||||
t.strictEqual(path.win32.isAbsolute('c:'), false);
|
||||
t.strictEqual(path.win32.isAbsolute('c:\\'), true);
|
||||
t.strictEqual(path.win32.isAbsolute('c:/'), true);
|
||||
t.strictEqual(path.win32.isAbsolute('c://'), true);
|
||||
t.strictEqual(path.win32.isAbsolute('C:/Users/'), true);
|
||||
t.strictEqual(path.win32.isAbsolute('C:\\Users\\'), true);
|
||||
t.strictEqual(path.win32.isAbsolute('C:cwd/another'), false);
|
||||
t.strictEqual(path.win32.isAbsolute('C:cwd\\another'), false);
|
||||
t.strictEqual(path.win32.isAbsolute('directory/directory'), false);
|
||||
t.strictEqual(path.win32.isAbsolute('directory\\directory'), false);
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('path.posix.isAbsolute', function (t) {
|
||||
t.strictEqual(path.posix.isAbsolute('/home/foo'), true);
|
||||
t.strictEqual(path.posix.isAbsolute('/home/foo/..'), true);
|
||||
t.strictEqual(path.posix.isAbsolute('bar/'), false);
|
||||
t.strictEqual(path.posix.isAbsolute('./baz'), false);
|
||||
t.end();
|
||||
});
|
126
node_modules/path-browserify/test/test-path-join.js
generated
vendored
Normal file
126
node_modules/path-browserify/test/test-path-join.js
generated
vendored
Normal file
@ -0,0 +1,126 @@
|
||||
'use strict';
|
||||
var tape = require('tape');
|
||||
var path = require('../');
|
||||
|
||||
var backslashRE = /\\/g;
|
||||
|
||||
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
|
||||
var windowsJoinTests =
|
||||
[// arguments result
|
||||
// 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']
|
||||
];
|
||||
|
||||
tape('path.posix.join', function (t) {
|
||||
joinTests.forEach(function (p) {
|
||||
var actual = path.posix.join.apply(null, p[0]);
|
||||
t.strictEqual(actual, p[1]);
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('path.win32.join', { skip: true }, function (t) {
|
||||
joinTests.forEach(function (p) {
|
||||
var actual = path.win32.join.apply(null, p[0]).replace(backslashRE, '/');
|
||||
t.strictEqual(actual, p[1]);
|
||||
});
|
||||
windowsJoinTests.forEach(function (p) {
|
||||
var actual = path.win32.join.apply(null, p[0]);
|
||||
t.strictEqual(actual, p[1]);
|
||||
});
|
||||
t.end();
|
||||
});
|
235
node_modules/path-browserify/test/test-path-parse-format.js
generated
vendored
Normal file
235
node_modules/path-browserify/test/test-path-parse-format.js
generated
vendored
Normal file
@ -0,0 +1,235 @@
|
||||
// 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.
|
||||
|
||||
'use strict';
|
||||
var tape = require('tape');
|
||||
var path = require('../');
|
||||
|
||||
var winPaths = [
|
||||
// [path, root]
|
||||
['C:\\path\\dir\\index.html', 'C:\\'],
|
||||
['C:\\another_path\\DIR\\1\\2\\33\\\\index', 'C:\\'],
|
||||
['another_path\\DIR with spaces\\1\\2\\33\\index', ''],
|
||||
['\\', '\\'],
|
||||
['\\foo\\C:', '\\'],
|
||||
['file', ''],
|
||||
['file:stream', ''],
|
||||
['.\\file', ''],
|
||||
['C:', 'C:'],
|
||||
['C:.', 'C:'],
|
||||
['C:..', 'C:'],
|
||||
['C:abc', 'C:'],
|
||||
['C:\\', 'C:\\'],
|
||||
['C:\\abc', 'C:\\' ],
|
||||
['', ''],
|
||||
|
||||
// unc
|
||||
['\\\\server\\share\\file_path', '\\\\server\\share\\'],
|
||||
['\\\\server two\\shared folder\\file path.zip',
|
||||
'\\\\server two\\shared folder\\'],
|
||||
['\\\\teela\\admin$\\system32', '\\\\teela\\admin$\\'],
|
||||
['\\\\?\\UNC\\server\\share', '\\\\?\\UNC\\']
|
||||
];
|
||||
|
||||
var winSpecialCaseParseTests = [
|
||||
['/foo/bar', { root: '/' }],
|
||||
];
|
||||
|
||||
var winSpecialCaseFormatTests = [
|
||||
[{ dir: 'some\\dir' }, 'some\\dir\\'],
|
||||
[{ base: 'index.html' }, 'index.html'],
|
||||
[{ root: 'C:\\' }, 'C:\\'],
|
||||
[{ name: 'index', ext: '.html' }, 'index.html'],
|
||||
[{ dir: 'some\\dir', name: 'index', ext: '.html' }, 'some\\dir\\index.html'],
|
||||
[{ root: 'C:\\', name: 'index', ext: '.html' }, 'C:\\index.html'],
|
||||
[{}, '']
|
||||
];
|
||||
|
||||
var unixPaths = [
|
||||
// [path, root]
|
||||
['/home/user/dir/file.txt', '/'],
|
||||
['/home/user/a dir/another File.zip', '/'],
|
||||
['/home/user/a dir//another&File.', '/'],
|
||||
['/home/user/a$$$dir//another File.zip', '/'],
|
||||
['user/dir/another File.zip', ''],
|
||||
['file', ''],
|
||||
['.\\file', ''],
|
||||
['./file', ''],
|
||||
['C:\\foo', ''],
|
||||
['/', '/'],
|
||||
['', ''],
|
||||
['.', ''],
|
||||
['..', ''],
|
||||
['/foo', '/'],
|
||||
['/foo.', '/'],
|
||||
['/foo.bar', '/'],
|
||||
['/.', '/'],
|
||||
['/.foo', '/'],
|
||||
['/.foo.bar', '/'],
|
||||
['/foo/bar.baz', '/']
|
||||
];
|
||||
|
||||
var unixSpecialCaseFormatTests = [
|
||||
[{ dir: 'some/dir' }, 'some/dir/'],
|
||||
[{ base: 'index.html' }, 'index.html'],
|
||||
[{ root: '/' }, '/'],
|
||||
[{ name: 'index', ext: '.html' }, 'index.html'],
|
||||
[{ dir: 'some/dir', name: 'index', ext: '.html' }, 'some/dir/index.html'],
|
||||
[{ root: '/', name: 'index', ext: '.html' }, '/index.html'],
|
||||
[{}, '']
|
||||
];
|
||||
|
||||
var errors = [
|
||||
{ method: 'parse', input: [null], message: TypeError },
|
||||
{ method: 'parse', input: [{}], message: TypeError },
|
||||
{ method: 'parse', input: [true], message: TypeError },
|
||||
{ method: 'parse', input: [1], message: TypeError },
|
||||
{ method: 'parse', input: [], message: TypeError },
|
||||
{ method: 'format', input: [null], message: TypeError },
|
||||
{ method: 'format', input: [''], message: TypeError },
|
||||
{ method: 'format', input: [true], message: TypeError },
|
||||
{ method: 'format', input: [1], message: TypeError },
|
||||
];
|
||||
|
||||
tape('path.win32.parse', { skip: true }, function (t) {
|
||||
checkParseFormat(t, path.win32, winPaths);
|
||||
checkSpecialCaseParseFormat(t, path.win32, winSpecialCaseParseTests);
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('path.posix.parse', function (t) {
|
||||
checkParseFormat(t, path.posix, unixPaths);
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('path.win32.parse errors', { skip: true }, function (t) {
|
||||
checkErrors(t, path.win32);
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('path.posix.parse errors', function (t) {
|
||||
checkErrors(t, path.posix);
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('path.win32.format', { skip: true }, function (t) {
|
||||
checkFormat(t, path.win32, winSpecialCaseFormatTests);
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('path.posix.format', function (t) {
|
||||
checkFormat(t, path.posix, unixSpecialCaseFormatTests);
|
||||
t.end();
|
||||
});
|
||||
|
||||
// Test removal of trailing path separators
|
||||
var windowsTrailingTests =
|
||||
[['.\\', { root: '', dir: '', base: '.', ext: '', name: '.' }],
|
||||
['\\\\', { root: '\\', dir: '\\', base: '', ext: '', name: '' }],
|
||||
['\\\\', { root: '\\', dir: '\\', base: '', ext: '', name: '' }],
|
||||
['c:\\foo\\\\\\',
|
||||
{ root: 'c:\\', dir: 'c:\\', base: 'foo', ext: '', name: 'foo' }],
|
||||
['D:\\foo\\\\\\bar.baz',
|
||||
{ root: 'D:\\',
|
||||
dir: 'D:\\foo\\\\',
|
||||
base: 'bar.baz',
|
||||
ext: '.baz',
|
||||
name: 'bar'
|
||||
}
|
||||
]
|
||||
];
|
||||
var posixTrailingTests =
|
||||
[['./', { root: '', dir: '', base: '.', ext: '', name: '.' }],
|
||||
['//', { root: '/', dir: '/', base: '', ext: '', name: '' }],
|
||||
['///', { root: '/', dir: '/', base: '', ext: '', name: '' }],
|
||||
['/foo///', { root: '/', dir: '/', base: 'foo', ext: '', name: 'foo' }],
|
||||
['/foo///bar.baz',
|
||||
{ root: '/', dir: '/foo//', base: 'bar.baz', ext: '.baz', name: 'bar' }
|
||||
]
|
||||
];
|
||||
|
||||
tape('path.win32.parse trailing', { skip: true }, function (t) {
|
||||
windowsTrailingTests.forEach(function (p) {
|
||||
var actual = path.win32.parse(p[0]);
|
||||
var expected = p[1];
|
||||
t.deepEqual(actual, expected)
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('path.posix.parse trailing', function (t) {
|
||||
posixTrailingTests.forEach(function (p) {
|
||||
var actual = path.posix.parse(p[0]);
|
||||
var expected = p[1];
|
||||
t.deepEqual(actual, expected)
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
function checkErrors(t, path) {
|
||||
errors.forEach(function(errorCase) {
|
||||
t.throws(function () {
|
||||
path[errorCase.method].apply(path, errorCase.input);
|
||||
}, errorCase.message);
|
||||
});
|
||||
}
|
||||
|
||||
function checkParseFormat(t, path, paths) {
|
||||
paths.forEach(function(p) {
|
||||
var element = p[0];
|
||||
var root = p[1];
|
||||
var output = path.parse(element);
|
||||
t.strictEqual(typeof output.root, 'string');
|
||||
t.strictEqual(typeof output.dir, 'string');
|
||||
t.strictEqual(typeof output.base, 'string');
|
||||
t.strictEqual(typeof output.ext, 'string');
|
||||
t.strictEqual(typeof output.name, 'string');
|
||||
t.strictEqual(path.format(output), element);
|
||||
t.strictEqual(output.root, root);
|
||||
t.ok(output.dir.startsWith(output.root));
|
||||
t.strictEqual(output.dir, output.dir ? path.dirname(element) : '');
|
||||
t.strictEqual(output.base, path.basename(element));
|
||||
t.strictEqual(output.ext, path.extname(element));
|
||||
});
|
||||
}
|
||||
|
||||
function checkSpecialCaseParseFormat(t, path, testCases) {
|
||||
testCases.forEach(function(testCase) {
|
||||
var element = testCase[0];
|
||||
var expect = testCase[1];
|
||||
var output = path.parse(element);
|
||||
Object.keys(expect).forEach(function(key) {
|
||||
t.strictEqual(output[key], expect[key]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function checkFormat(t, path, testCases) {
|
||||
testCases.forEach(function(testCase) {
|
||||
t.strictEqual(path.format(testCase[0]), testCase[1]);
|
||||
});
|
||||
|
||||
[null, undefined, 1, true, false, 'string'].forEach(function (pathObject) {
|
||||
t.throws(function() {
|
||||
path.format(pathObject);
|
||||
}, /The "pathObject" argument must be of type Object. Received type (\w+)/);
|
||||
});
|
||||
}
|
66
node_modules/path-browserify/test/test-path-relative.js
generated
vendored
Normal file
66
node_modules/path-browserify/test/test-path-relative.js
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
'use strict';
|
||||
var tape = require('tape');
|
||||
var path = require('../');
|
||||
|
||||
var relativeTests = {
|
||||
win32:
|
||||
// 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:\\'],
|
||||
['c:/AaAa/bbbb', 'c:/aaaa/bbbb', ''],
|
||||
['c:/aaaaa/', 'c:/aaaa/cccc', '..\\aaaa\\cccc'],
|
||||
['C:\\foo\\bar\\baz\\quux', 'C:\\', '..\\..\\..\\..'],
|
||||
['C:\\foo\\test', 'C:\\foo\\test\\bar\\package.json', 'bar\\package.json'],
|
||||
['C:\\foo\\bar\\baz-quux', 'C:\\foo\\bar\\baz', '..\\baz'],
|
||||
['C:\\foo\\bar\\baz', 'C:\\foo\\bar\\baz-quux', '..\\baz-quux'],
|
||||
['\\\\foo\\bar', '\\\\foo\\bar\\baz', 'baz'],
|
||||
['\\\\foo\\bar\\baz', '\\\\foo\\bar', '..'],
|
||||
['\\\\foo\\bar\\baz-quux', '\\\\foo\\bar\\baz', '..\\baz'],
|
||||
['\\\\foo\\bar\\baz', '\\\\foo\\bar\\baz-quux', '..\\baz-quux'],
|
||||
['C:\\baz-quux', 'C:\\baz', '..\\baz'],
|
||||
['C:\\baz', 'C:\\baz-quux', '..\\baz-quux'],
|
||||
['\\\\foo\\baz-quux', '\\\\foo\\baz', '..\\baz'],
|
||||
['\\\\foo\\baz', '\\\\foo\\baz-quux', '..\\baz-quux'],
|
||||
['C:\\baz', '\\\\foo\\bar\\baz', '\\\\foo\\bar\\baz'],
|
||||
['\\\\foo\\bar\\baz', 'C:\\baz', 'C:\\baz']
|
||||
],
|
||||
posix:
|
||||
// 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'],
|
||||
['/foo/test', '/foo/test/bar/package.json', 'bar/package.json'],
|
||||
['/Users/a/web/b/test/mails', '/Users/a/web/b', '../..'],
|
||||
['/foo/bar/baz-quux', '/foo/bar/baz', '../baz'],
|
||||
['/foo/bar/baz', '/foo/bar/baz-quux', '../baz-quux'],
|
||||
['/baz-quux', '/baz', '../baz'],
|
||||
['/baz', '/baz-quux', '../baz-quux']
|
||||
]
|
||||
};
|
||||
|
||||
tape('path.posix.relative', function (t) {
|
||||
relativeTests.posix.forEach(function (p) {
|
||||
var expected = p[2];
|
||||
var actual = path.posix.relative(p[0], p[1]);
|
||||
t.strictEqual(actual, expected);
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('path.win32.relative', { skip: true }, function (t) {
|
||||
relativeTests.win32.forEach(function (p) {
|
||||
var expected = p[2];
|
||||
var actual = path.win32.relative(p[0], p[1]);
|
||||
t.strictEqual(actual, expected);
|
||||
});
|
||||
t.end();
|
||||
});
|
45
node_modules/path-browserify/test/test-path-resolve.js
generated
vendored
Normal file
45
node_modules/path-browserify/test/test-path-resolve.js
generated
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
'use strict';
|
||||
var tape = require('tape');
|
||||
var path = require('../');
|
||||
|
||||
var windowsTests =
|
||||
// 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'],
|
||||
[['C:\\foo\\tmp.3\\', '..\\tmp.3\\cycles\\root.js'],
|
||||
'C:\\foo\\tmp.3\\cycles\\root.js']
|
||||
];
|
||||
var posixTests =
|
||||
// arguments result
|
||||
[[['/var/lib', '../', 'file/'], '/var/file'],
|
||||
[['/var/lib', '/../', 'file/'], '/file'],
|
||||
[['a/b/c/', '../../..'], process.cwd()],
|
||||
[['.'], process.cwd()],
|
||||
[['/some/dir', '.', '/absolute/'], '/absolute'],
|
||||
[['/foo/tmp.3/', '../tmp.3/cycles/root.js'], '/foo/tmp.3/cycles/root.js']
|
||||
];
|
||||
|
||||
tape('path.posix.resolve', function (t) {
|
||||
posixTests.forEach(function (p) {
|
||||
var actual = path.posix.resolve.apply(null, p[0]);
|
||||
t.strictEqual(actual, p[1]);
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('path.win32.resolve', { skip: true }, function (t) {
|
||||
windowsTests.forEach(function (p) {
|
||||
var actual = path.win32.resolve.apply(null, p[0]);
|
||||
t.strictEqual(actual, p[1]);
|
||||
});
|
||||
t.end();
|
||||
});
|
53
node_modules/path-browserify/test/test-path-zero-length-strings.js
generated
vendored
Normal file
53
node_modules/path-browserify/test/test-path-zero-length-strings.js
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
'use strict';
|
||||
|
||||
// These testcases are specific to one uncommon behavior in path module. Few
|
||||
// of the functions in path module, treat '' strings as current working
|
||||
// directory. This test makes sure that the behavior is intact between commits.
|
||||
// See: https://github.com/nodejs/node/pull/2106
|
||||
|
||||
var tape = require('tape');
|
||||
var path = require('../');
|
||||
var pwd = process.cwd();
|
||||
|
||||
tape('path.join zero-length', function (t) {
|
||||
// join will internally ignore all the zero-length strings and it will return
|
||||
// '.' if the joined string is a zero-length string.
|
||||
t.strictEqual(path.posix.join(''), '.');
|
||||
t.strictEqual(path.posix.join('', ''), '.');
|
||||
if (path.win32) t.strictEqual(path.win32.join(''), '.');
|
||||
if (path.win32) t.strictEqual(path.win32.join('', ''), '.');
|
||||
t.strictEqual(path.join(pwd), pwd);
|
||||
t.strictEqual(path.join(pwd, ''), pwd);
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('path.normalize zero-length', function (t) {
|
||||
// normalize will return '.' if the input is a zero-length string
|
||||
t.strictEqual(path.posix.normalize(''), '.');
|
||||
if (path.win32) t.strictEqual(path.win32.normalize(''), '.');
|
||||
t.strictEqual(path.normalize(pwd), pwd);
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('path.isAbsolute zero-length', function (t) {
|
||||
// Since '' is not a valid path in any of the common environments, return false
|
||||
t.strictEqual(path.posix.isAbsolute(''), false);
|
||||
if (path.win32) t.strictEqual(path.win32.isAbsolute(''), false);
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('path.resolve zero-length', function (t) {
|
||||
// resolve, internally ignores all the zero-length strings and returns the
|
||||
// current working directory
|
||||
t.strictEqual(path.resolve(''), pwd);
|
||||
t.strictEqual(path.resolve('', ''), pwd);
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('path.relative zero-length', function (t) {
|
||||
// relative, internally calls resolve. So, '' is actually the current directory
|
||||
t.strictEqual(path.relative('', pwd), '');
|
||||
t.strictEqual(path.relative(pwd, ''), '');
|
||||
t.strictEqual(path.relative(pwd, pwd), '');
|
||||
t.end();
|
||||
});
|
107
node_modules/path-browserify/test/test-path.js
generated
vendored
Normal file
107
node_modules/path-browserify/test/test-path.js
generated
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
// 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.
|
||||
|
||||
'use strict';
|
||||
var tape = require('tape');
|
||||
var path = require('../');
|
||||
|
||||
// Test thrown TypeErrors
|
||||
var typeErrorTests = [true, false, 7, null, {}, undefined, [], NaN];
|
||||
|
||||
function fail(t, fn) {
|
||||
var args = [].slice.call(arguments, 1);
|
||||
|
||||
t.throws(function () {
|
||||
fn.apply(null, args);
|
||||
}, TypeError);
|
||||
}
|
||||
|
||||
tape('path.posix TypeErrors', function (t) {
|
||||
typeErrorTests.forEach(function (test) {
|
||||
fail(t, path.posix.join, test);
|
||||
fail(t, path.posix.resolve, test);
|
||||
fail(t, path.posix.normalize, test);
|
||||
fail(t, path.posix.isAbsolute, test);
|
||||
fail(t, path.posix.relative, test, 'foo');
|
||||
fail(t, path.posix.relative, 'foo', test);
|
||||
fail(t, path.posix.parse, test);
|
||||
fail(t, path.posix.dirname, test);
|
||||
fail(t, path.posix.basename, test);
|
||||
fail(t, path.posix.extname, test);
|
||||
|
||||
// undefined is a valid value as the second argument to basename
|
||||
if (test !== undefined) {
|
||||
fail(t, path.posix.basename, 'foo', test);
|
||||
}
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('path.win32 TypeErrors', { skip: true }, function (t) {
|
||||
typeErrorTests.forEach(function (test) {
|
||||
fail(t, path.win32.join, test);
|
||||
fail(t, path.win32.resolve, test);
|
||||
fail(t, path.win32.normalize, test);
|
||||
fail(t, path.win32.isAbsolute, test);
|
||||
fail(t, path.win32.relative, test, 'foo');
|
||||
fail(t, path.win32.relative, 'foo', test);
|
||||
fail(t, path.win32.parse, test);
|
||||
fail(t, path.win32.dirname, test);
|
||||
fail(t, path.win32.basename, test);
|
||||
fail(t, path.win32.extname, test);
|
||||
|
||||
// undefined is a valid value as the second argument to basename
|
||||
if (test !== undefined) {
|
||||
fail(t, path.win32.basename, 'foo', test);
|
||||
}
|
||||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
// path.sep tests
|
||||
tape('path.win32.sep', { skip: true }, function (t) {
|
||||
// windows
|
||||
t.strictEqual(path.win32.sep, '\\');
|
||||
t.end();
|
||||
});
|
||||
tape('path.posix.sep', function (t) {
|
||||
// posix
|
||||
t.strictEqual(path.posix.sep, '/');
|
||||
t.end();
|
||||
});
|
||||
|
||||
// path.delimiter tests
|
||||
tape('path.win32.delimiter', { skip: true }, function (t) {
|
||||
// windows
|
||||
t.strictEqual(path.win32.delimiter, ';');
|
||||
t.end();
|
||||
});
|
||||
tape('path.posix.delimiter', function (t) {
|
||||
// posix
|
||||
t.strictEqual(path.posix.delimiter, ':');
|
||||
t.end();
|
||||
});
|
||||
|
||||
tape('path', function (t) {
|
||||
t.strictEqual(path, path.posix);
|
||||
t.end();
|
||||
});
|
||||
|
Reference in New Issue
Block a user