You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1773 lines
47 KiB
JavaScript
1773 lines
47 KiB
JavaScript
(self["webpackChunk_JUPYTERLAB_CORE_OUTPUT"] = self["webpackChunk_JUPYTERLAB_CORE_OUTPUT"] || []).push([[383,7061],{
|
|
|
|
/***/ 66161:
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
function hasKey(obj, keys) {
|
|
var o = obj;
|
|
keys.slice(0, -1).forEach(function (key) {
|
|
o = o[key] || {};
|
|
});
|
|
|
|
var key = keys[keys.length - 1];
|
|
return key in o;
|
|
}
|
|
|
|
function isNumber(x) {
|
|
if (typeof x === 'number') { return true; }
|
|
if ((/^0x[0-9a-f]+$/i).test(x)) { return true; }
|
|
return (/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/).test(x);
|
|
}
|
|
|
|
function isConstructorOrProto(obj, key) {
|
|
return (key === 'constructor' && typeof obj[key] === 'function') || key === '__proto__';
|
|
}
|
|
|
|
module.exports = function (args, opts) {
|
|
if (!opts) { opts = {}; }
|
|
|
|
var flags = {
|
|
bools: {},
|
|
strings: {},
|
|
unknownFn: null,
|
|
};
|
|
|
|
if (typeof opts.unknown === 'function') {
|
|
flags.unknownFn = opts.unknown;
|
|
}
|
|
|
|
if (typeof opts.boolean === 'boolean' && opts.boolean) {
|
|
flags.allBools = true;
|
|
} else {
|
|
[].concat(opts.boolean).filter(Boolean).forEach(function (key) {
|
|
flags.bools[key] = true;
|
|
});
|
|
}
|
|
|
|
var aliases = {};
|
|
|
|
function aliasIsBoolean(key) {
|
|
return aliases[key].some(function (x) {
|
|
return flags.bools[x];
|
|
});
|
|
}
|
|
|
|
Object.keys(opts.alias || {}).forEach(function (key) {
|
|
aliases[key] = [].concat(opts.alias[key]);
|
|
aliases[key].forEach(function (x) {
|
|
aliases[x] = [key].concat(aliases[key].filter(function (y) {
|
|
return x !== y;
|
|
}));
|
|
});
|
|
});
|
|
|
|
[].concat(opts.string).filter(Boolean).forEach(function (key) {
|
|
flags.strings[key] = true;
|
|
if (aliases[key]) {
|
|
[].concat(aliases[key]).forEach(function (k) {
|
|
flags.strings[k] = true;
|
|
});
|
|
}
|
|
});
|
|
|
|
var defaults = opts.default || {};
|
|
|
|
var argv = { _: [] };
|
|
|
|
function argDefined(key, arg) {
|
|
return (flags.allBools && (/^--[^=]+$/).test(arg))
|
|
|| flags.strings[key]
|
|
|| flags.bools[key]
|
|
|| aliases[key];
|
|
}
|
|
|
|
function setKey(obj, keys, value) {
|
|
var o = obj;
|
|
for (var i = 0; i < keys.length - 1; i++) {
|
|
var key = keys[i];
|
|
if (isConstructorOrProto(o, key)) { return; }
|
|
if (o[key] === undefined) { o[key] = {}; }
|
|
if (
|
|
o[key] === Object.prototype
|
|
|| o[key] === Number.prototype
|
|
|| o[key] === String.prototype
|
|
) {
|
|
o[key] = {};
|
|
}
|
|
if (o[key] === Array.prototype) { o[key] = []; }
|
|
o = o[key];
|
|
}
|
|
|
|
var lastKey = keys[keys.length - 1];
|
|
if (isConstructorOrProto(o, lastKey)) { return; }
|
|
if (
|
|
o === Object.prototype
|
|
|| o === Number.prototype
|
|
|| o === String.prototype
|
|
) {
|
|
o = {};
|
|
}
|
|
if (o === Array.prototype) { o = []; }
|
|
if (o[lastKey] === undefined || flags.bools[lastKey] || typeof o[lastKey] === 'boolean') {
|
|
o[lastKey] = value;
|
|
} else if (Array.isArray(o[lastKey])) {
|
|
o[lastKey].push(value);
|
|
} else {
|
|
o[lastKey] = [o[lastKey], value];
|
|
}
|
|
}
|
|
|
|
function setArg(key, val, arg) {
|
|
if (arg && flags.unknownFn && !argDefined(key, arg)) {
|
|
if (flags.unknownFn(arg) === false) { return; }
|
|
}
|
|
|
|
var value = !flags.strings[key] && isNumber(val)
|
|
? Number(val)
|
|
: val;
|
|
setKey(argv, key.split('.'), value);
|
|
|
|
(aliases[key] || []).forEach(function (x) {
|
|
setKey(argv, x.split('.'), value);
|
|
});
|
|
}
|
|
|
|
Object.keys(flags.bools).forEach(function (key) {
|
|
setArg(key, defaults[key] === undefined ? false : defaults[key]);
|
|
});
|
|
|
|
var notFlags = [];
|
|
|
|
if (args.indexOf('--') !== -1) {
|
|
notFlags = args.slice(args.indexOf('--') + 1);
|
|
args = args.slice(0, args.indexOf('--'));
|
|
}
|
|
|
|
for (var i = 0; i < args.length; i++) {
|
|
var arg = args[i];
|
|
var key;
|
|
var next;
|
|
|
|
if ((/^--.+=/).test(arg)) {
|
|
// Using [\s\S] instead of . because js doesn't support the
|
|
// 'dotall' regex modifier. See:
|
|
// http://stackoverflow.com/a/1068308/13216
|
|
var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
|
|
key = m[1];
|
|
var value = m[2];
|
|
if (flags.bools[key]) {
|
|
value = value !== 'false';
|
|
}
|
|
setArg(key, value, arg);
|
|
} else if ((/^--no-.+/).test(arg)) {
|
|
key = arg.match(/^--no-(.+)/)[1];
|
|
setArg(key, false, arg);
|
|
} else if ((/^--.+/).test(arg)) {
|
|
key = arg.match(/^--(.+)/)[1];
|
|
next = args[i + 1];
|
|
if (
|
|
next !== undefined
|
|
&& !(/^(-|--)[^-]/).test(next)
|
|
&& !flags.bools[key]
|
|
&& !flags.allBools
|
|
&& (aliases[key] ? !aliasIsBoolean(key) : true)
|
|
) {
|
|
setArg(key, next, arg);
|
|
i += 1;
|
|
} else if ((/^(true|false)$/).test(next)) {
|
|
setArg(key, next === 'true', arg);
|
|
i += 1;
|
|
} else {
|
|
setArg(key, flags.strings[key] ? '' : true, arg);
|
|
}
|
|
} else if ((/^-[^-]+/).test(arg)) {
|
|
var letters = arg.slice(1, -1).split('');
|
|
|
|
var broken = false;
|
|
for (var j = 0; j < letters.length; j++) {
|
|
next = arg.slice(j + 2);
|
|
|
|
if (next === '-') {
|
|
setArg(letters[j], next, arg);
|
|
continue;
|
|
}
|
|
|
|
if ((/[A-Za-z]/).test(letters[j]) && next[0] === '=') {
|
|
setArg(letters[j], next.slice(1), arg);
|
|
broken = true;
|
|
break;
|
|
}
|
|
|
|
if (
|
|
(/[A-Za-z]/).test(letters[j])
|
|
&& (/-?\d+(\.\d*)?(e-?\d+)?$/).test(next)
|
|
) {
|
|
setArg(letters[j], next, arg);
|
|
broken = true;
|
|
break;
|
|
}
|
|
|
|
if (letters[j + 1] && letters[j + 1].match(/\W/)) {
|
|
setArg(letters[j], arg.slice(j + 2), arg);
|
|
broken = true;
|
|
break;
|
|
} else {
|
|
setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
|
|
}
|
|
}
|
|
|
|
key = arg.slice(-1)[0];
|
|
if (!broken && key !== '-') {
|
|
if (
|
|
args[i + 1]
|
|
&& !(/^(-|--)[^-]/).test(args[i + 1])
|
|
&& !flags.bools[key]
|
|
&& (aliases[key] ? !aliasIsBoolean(key) : true)
|
|
) {
|
|
setArg(key, args[i + 1], arg);
|
|
i += 1;
|
|
} else if (args[i + 1] && (/^(true|false)$/).test(args[i + 1])) {
|
|
setArg(key, args[i + 1] === 'true', arg);
|
|
i += 1;
|
|
} else {
|
|
setArg(key, flags.strings[key] ? '' : true, arg);
|
|
}
|
|
}
|
|
} else {
|
|
if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
|
|
argv._.push(flags.strings._ || !isNumber(arg) ? arg : Number(arg));
|
|
}
|
|
if (opts.stopEarly) {
|
|
argv._.push.apply(argv._, args.slice(i + 1));
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
Object.keys(defaults).forEach(function (k) {
|
|
if (!hasKey(argv, k.split('.'))) {
|
|
setKey(argv, k.split('.'), defaults[k]);
|
|
|
|
(aliases[k] || []).forEach(function (x) {
|
|
setKey(argv, x.split('.'), defaults[k]);
|
|
});
|
|
}
|
|
});
|
|
|
|
if (opts['--']) {
|
|
argv['--'] = notFlags.slice();
|
|
} else {
|
|
notFlags.forEach(function (k) {
|
|
argv._.push(k);
|
|
});
|
|
}
|
|
|
|
return argv;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 67425:
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
/* provided dependency */ var process = __webpack_require__(27061);
|
|
// '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.
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 27061:
|
|
/***/ ((module) => {
|
|
|
|
// shim for using process in browser
|
|
var process = module.exports = {};
|
|
|
|
// cached from whatever global is present so that test runners that stub it
|
|
// don't break things. But we need to wrap it in a try catch in case it is
|
|
// wrapped in strict mode code which doesn't define any globals. It's inside a
|
|
// function because try/catches deoptimize in certain engines.
|
|
|
|
var cachedSetTimeout;
|
|
var cachedClearTimeout;
|
|
|
|
function defaultSetTimout() {
|
|
throw new Error('setTimeout has not been defined');
|
|
}
|
|
function defaultClearTimeout () {
|
|
throw new Error('clearTimeout has not been defined');
|
|
}
|
|
(function () {
|
|
try {
|
|
if (typeof setTimeout === 'function') {
|
|
cachedSetTimeout = setTimeout;
|
|
} else {
|
|
cachedSetTimeout = defaultSetTimout;
|
|
}
|
|
} catch (e) {
|
|
cachedSetTimeout = defaultSetTimout;
|
|
}
|
|
try {
|
|
if (typeof clearTimeout === 'function') {
|
|
cachedClearTimeout = clearTimeout;
|
|
} else {
|
|
cachedClearTimeout = defaultClearTimeout;
|
|
}
|
|
} catch (e) {
|
|
cachedClearTimeout = defaultClearTimeout;
|
|
}
|
|
} ())
|
|
function runTimeout(fun) {
|
|
if (cachedSetTimeout === setTimeout) {
|
|
//normal enviroments in sane situations
|
|
return setTimeout(fun, 0);
|
|
}
|
|
// if setTimeout wasn't available but was latter defined
|
|
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
|
cachedSetTimeout = setTimeout;
|
|
return setTimeout(fun, 0);
|
|
}
|
|
try {
|
|
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
return cachedSetTimeout(fun, 0);
|
|
} catch(e){
|
|
try {
|
|
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
|
return cachedSetTimeout.call(null, fun, 0);
|
|
} catch(e){
|
|
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
|
|
return cachedSetTimeout.call(this, fun, 0);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
function runClearTimeout(marker) {
|
|
if (cachedClearTimeout === clearTimeout) {
|
|
//normal enviroments in sane situations
|
|
return clearTimeout(marker);
|
|
}
|
|
// if clearTimeout wasn't available but was latter defined
|
|
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
|
cachedClearTimeout = clearTimeout;
|
|
return clearTimeout(marker);
|
|
}
|
|
try {
|
|
// when when somebody has screwed with setTimeout but no I.E. maddness
|
|
return cachedClearTimeout(marker);
|
|
} catch (e){
|
|
try {
|
|
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
|
|
return cachedClearTimeout.call(null, marker);
|
|
} catch (e){
|
|
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
|
|
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
|
|
return cachedClearTimeout.call(this, marker);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
var queue = [];
|
|
var draining = false;
|
|
var currentQueue;
|
|
var queueIndex = -1;
|
|
|
|
function cleanUpNextTick() {
|
|
if (!draining || !currentQueue) {
|
|
return;
|
|
}
|
|
draining = false;
|
|
if (currentQueue.length) {
|
|
queue = currentQueue.concat(queue);
|
|
} else {
|
|
queueIndex = -1;
|
|
}
|
|
if (queue.length) {
|
|
drainQueue();
|
|
}
|
|
}
|
|
|
|
function drainQueue() {
|
|
if (draining) {
|
|
return;
|
|
}
|
|
var timeout = runTimeout(cleanUpNextTick);
|
|
draining = true;
|
|
|
|
var len = queue.length;
|
|
while(len) {
|
|
currentQueue = queue;
|
|
queue = [];
|
|
while (++queueIndex < len) {
|
|
if (currentQueue) {
|
|
currentQueue[queueIndex].run();
|
|
}
|
|
}
|
|
queueIndex = -1;
|
|
len = queue.length;
|
|
}
|
|
currentQueue = null;
|
|
draining = false;
|
|
runClearTimeout(timeout);
|
|
}
|
|
|
|
process.nextTick = function (fun) {
|
|
var args = new Array(arguments.length - 1);
|
|
if (arguments.length > 1) {
|
|
for (var i = 1; i < arguments.length; i++) {
|
|
args[i - 1] = arguments[i];
|
|
}
|
|
}
|
|
queue.push(new Item(fun, args));
|
|
if (queue.length === 1 && !draining) {
|
|
runTimeout(drainQueue);
|
|
}
|
|
};
|
|
|
|
// v8 likes predictible objects
|
|
function Item(fun, array) {
|
|
this.fun = fun;
|
|
this.array = array;
|
|
}
|
|
Item.prototype.run = function () {
|
|
this.fun.apply(null, this.array);
|
|
};
|
|
process.title = 'browser';
|
|
process.browser = true;
|
|
process.env = {};
|
|
process.argv = [];
|
|
process.version = ''; // empty string to avoid regexp issues
|
|
process.versions = {};
|
|
|
|
function noop() {}
|
|
|
|
process.on = noop;
|
|
process.addListener = noop;
|
|
process.once = noop;
|
|
process.off = noop;
|
|
process.removeListener = noop;
|
|
process.removeAllListeners = noop;
|
|
process.emit = noop;
|
|
process.prependListener = noop;
|
|
process.prependOnceListener = noop;
|
|
|
|
process.listeners = function (name) { return [] }
|
|
|
|
process.binding = function (name) {
|
|
throw new Error('process.binding is not supported');
|
|
};
|
|
|
|
process.cwd = function () { return '/' };
|
|
process.chdir = function (dir) {
|
|
throw new Error('process.chdir is not supported');
|
|
};
|
|
process.umask = function() { return 0; };
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 88157:
|
|
/***/ ((__unused_webpack_module, exports) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var has = Object.prototype.hasOwnProperty
|
|
, undef;
|
|
|
|
/**
|
|
* Decode a URI encoded string.
|
|
*
|
|
* @param {String} input The URI encoded string.
|
|
* @returns {String|Null} The decoded string.
|
|
* @api private
|
|
*/
|
|
function decode(input) {
|
|
try {
|
|
return decodeURIComponent(input.replace(/\+/g, ' '));
|
|
} catch (e) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Attempts to encode a given input.
|
|
*
|
|
* @param {String} input The string that needs to be encoded.
|
|
* @returns {String|Null} The encoded string.
|
|
* @api private
|
|
*/
|
|
function encode(input) {
|
|
try {
|
|
return encodeURIComponent(input);
|
|
} catch (e) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Simple query string parser.
|
|
*
|
|
* @param {String} query The query string that needs to be parsed.
|
|
* @returns {Object}
|
|
* @api public
|
|
*/
|
|
function querystring(query) {
|
|
var parser = /([^=?#&]+)=?([^&]*)/g
|
|
, result = {}
|
|
, part;
|
|
|
|
while (part = parser.exec(query)) {
|
|
var key = decode(part[1])
|
|
, value = decode(part[2]);
|
|
|
|
//
|
|
// Prevent overriding of existing properties. This ensures that build-in
|
|
// methods like `toString` or __proto__ are not overriden by malicious
|
|
// querystrings.
|
|
//
|
|
// In the case if failed decoding, we want to omit the key/value pairs
|
|
// from the result.
|
|
//
|
|
if (key === null || value === null || key in result) continue;
|
|
result[key] = value;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Transform a query string to an object.
|
|
*
|
|
* @param {Object} obj Object that should be transformed.
|
|
* @param {String} prefix Optional prefix.
|
|
* @returns {String}
|
|
* @api public
|
|
*/
|
|
function querystringify(obj, prefix) {
|
|
prefix = prefix || '';
|
|
|
|
var pairs = []
|
|
, value
|
|
, key;
|
|
|
|
//
|
|
// Optionally prefix with a '?' if needed
|
|
//
|
|
if ('string' !== typeof prefix) prefix = '?';
|
|
|
|
for (key in obj) {
|
|
if (has.call(obj, key)) {
|
|
value = obj[key];
|
|
|
|
//
|
|
// Edge cases where we actually want to encode the value to an empty
|
|
// string instead of the stringified value.
|
|
//
|
|
if (!value && (value === null || value === undef || isNaN(value))) {
|
|
value = '';
|
|
}
|
|
|
|
key = encode(key);
|
|
value = encode(value);
|
|
|
|
//
|
|
// If we failed to encode the strings, we should bail out as we don't
|
|
// want to add invalid strings to the query.
|
|
//
|
|
if (key === null || value === null) continue;
|
|
pairs.push(key +'='+ value);
|
|
}
|
|
}
|
|
|
|
return pairs.length ? prefix + pairs.join('&') : '';
|
|
}
|
|
|
|
//
|
|
// Expose the module.
|
|
//
|
|
exports.stringify = querystringify;
|
|
exports.parse = querystring;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 53096:
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
/**
|
|
* Check if we're required to add a port number.
|
|
*
|
|
* @see https://url.spec.whatwg.org/#default-port
|
|
* @param {Number|String} port Port number we need to check
|
|
* @param {String} protocol Protocol we need to check against.
|
|
* @returns {Boolean} Is it a default port for the given protocol
|
|
* @api private
|
|
*/
|
|
module.exports = function required(port, protocol) {
|
|
protocol = protocol.split(':')[0];
|
|
port = +port;
|
|
|
|
if (!port) return false;
|
|
|
|
switch (protocol) {
|
|
case 'http':
|
|
case 'ws':
|
|
return port !== 80;
|
|
|
|
case 'https':
|
|
case 'wss':
|
|
return port !== 443;
|
|
|
|
case 'ftp':
|
|
return port !== 21;
|
|
|
|
case 'gopher':
|
|
return port !== 70;
|
|
|
|
case 'file':
|
|
return false;
|
|
}
|
|
|
|
return port !== 0;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 80899:
|
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var required = __webpack_require__(53096)
|
|
, qs = __webpack_require__(88157)
|
|
, controlOrWhitespace = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/
|
|
, CRHTLF = /[\n\r\t]/g
|
|
, slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//
|
|
, port = /:\d+$/
|
|
, protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i
|
|
, windowsDriveLetter = /^[a-zA-Z]:/;
|
|
|
|
/**
|
|
* Remove control characters and whitespace from the beginning of a string.
|
|
*
|
|
* @param {Object|String} str String to trim.
|
|
* @returns {String} A new string representing `str` stripped of control
|
|
* characters and whitespace from its beginning.
|
|
* @public
|
|
*/
|
|
function trimLeft(str) {
|
|
return (str ? str : '').toString().replace(controlOrWhitespace, '');
|
|
}
|
|
|
|
/**
|
|
* These are the parse rules for the URL parser, it informs the parser
|
|
* about:
|
|
*
|
|
* 0. The char it Needs to parse, if it's a string it should be done using
|
|
* indexOf, RegExp using exec and NaN means set as current value.
|
|
* 1. The property we should set when parsing this value.
|
|
* 2. Indication if it's backwards or forward parsing, when set as number it's
|
|
* the value of extra chars that should be split off.
|
|
* 3. Inherit from location if non existing in the parser.
|
|
* 4. `toLowerCase` the resulting value.
|
|
*/
|
|
var rules = [
|
|
['#', 'hash'], // Extract from the back.
|
|
['?', 'query'], // Extract from the back.
|
|
function sanitize(address, url) { // Sanitize what is left of the address
|
|
return isSpecial(url.protocol) ? address.replace(/\\/g, '/') : address;
|
|
},
|
|
['/', 'pathname'], // Extract from the back.
|
|
['@', 'auth', 1], // Extract from the front.
|
|
[NaN, 'host', undefined, 1, 1], // Set left over value.
|
|
[/:(\d*)$/, 'port', undefined, 1], // RegExp the back.
|
|
[NaN, 'hostname', undefined, 1, 1] // Set left over.
|
|
];
|
|
|
|
/**
|
|
* These properties should not be copied or inherited from. This is only needed
|
|
* for all non blob URL's as a blob URL does not include a hash, only the
|
|
* origin.
|
|
*
|
|
* @type {Object}
|
|
* @private
|
|
*/
|
|
var ignore = { hash: 1, query: 1 };
|
|
|
|
/**
|
|
* The location object differs when your code is loaded through a normal page,
|
|
* Worker or through a worker using a blob. And with the blobble begins the
|
|
* trouble as the location object will contain the URL of the blob, not the
|
|
* location of the page where our code is loaded in. The actual origin is
|
|
* encoded in the `pathname` so we can thankfully generate a good "default"
|
|
* location from it so we can generate proper relative URL's again.
|
|
*
|
|
* @param {Object|String} loc Optional default location object.
|
|
* @returns {Object} lolcation object.
|
|
* @public
|
|
*/
|
|
function lolcation(loc) {
|
|
var globalVar;
|
|
|
|
if (typeof window !== 'undefined') globalVar = window;
|
|
else if (typeof __webpack_require__.g !== 'undefined') globalVar = __webpack_require__.g;
|
|
else if (typeof self !== 'undefined') globalVar = self;
|
|
else globalVar = {};
|
|
|
|
var location = globalVar.location || {};
|
|
loc = loc || location;
|
|
|
|
var finaldestination = {}
|
|
, type = typeof loc
|
|
, key;
|
|
|
|
if ('blob:' === loc.protocol) {
|
|
finaldestination = new Url(unescape(loc.pathname), {});
|
|
} else if ('string' === type) {
|
|
finaldestination = new Url(loc, {});
|
|
for (key in ignore) delete finaldestination[key];
|
|
} else if ('object' === type) {
|
|
for (key in loc) {
|
|
if (key in ignore) continue;
|
|
finaldestination[key] = loc[key];
|
|
}
|
|
|
|
if (finaldestination.slashes === undefined) {
|
|
finaldestination.slashes = slashes.test(loc.href);
|
|
}
|
|
}
|
|
|
|
return finaldestination;
|
|
}
|
|
|
|
/**
|
|
* Check whether a protocol scheme is special.
|
|
*
|
|
* @param {String} The protocol scheme of the URL
|
|
* @return {Boolean} `true` if the protocol scheme is special, else `false`
|
|
* @private
|
|
*/
|
|
function isSpecial(scheme) {
|
|
return (
|
|
scheme === 'file:' ||
|
|
scheme === 'ftp:' ||
|
|
scheme === 'http:' ||
|
|
scheme === 'https:' ||
|
|
scheme === 'ws:' ||
|
|
scheme === 'wss:'
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @typedef ProtocolExtract
|
|
* @type Object
|
|
* @property {String} protocol Protocol matched in the URL, in lowercase.
|
|
* @property {Boolean} slashes `true` if protocol is followed by "//", else `false`.
|
|
* @property {String} rest Rest of the URL that is not part of the protocol.
|
|
*/
|
|
|
|
/**
|
|
* Extract protocol information from a URL with/without double slash ("//").
|
|
*
|
|
* @param {String} address URL we want to extract from.
|
|
* @param {Object} location
|
|
* @return {ProtocolExtract} Extracted information.
|
|
* @private
|
|
*/
|
|
function extractProtocol(address, location) {
|
|
address = trimLeft(address);
|
|
address = address.replace(CRHTLF, '');
|
|
location = location || {};
|
|
|
|
var match = protocolre.exec(address);
|
|
var protocol = match[1] ? match[1].toLowerCase() : '';
|
|
var forwardSlashes = !!match[2];
|
|
var otherSlashes = !!match[3];
|
|
var slashesCount = 0;
|
|
var rest;
|
|
|
|
if (forwardSlashes) {
|
|
if (otherSlashes) {
|
|
rest = match[2] + match[3] + match[4];
|
|
slashesCount = match[2].length + match[3].length;
|
|
} else {
|
|
rest = match[2] + match[4];
|
|
slashesCount = match[2].length;
|
|
}
|
|
} else {
|
|
if (otherSlashes) {
|
|
rest = match[3] + match[4];
|
|
slashesCount = match[3].length;
|
|
} else {
|
|
rest = match[4]
|
|
}
|
|
}
|
|
|
|
if (protocol === 'file:') {
|
|
if (slashesCount >= 2) {
|
|
rest = rest.slice(2);
|
|
}
|
|
} else if (isSpecial(protocol)) {
|
|
rest = match[4];
|
|
} else if (protocol) {
|
|
if (forwardSlashes) {
|
|
rest = rest.slice(2);
|
|
}
|
|
} else if (slashesCount >= 2 && isSpecial(location.protocol)) {
|
|
rest = match[4];
|
|
}
|
|
|
|
return {
|
|
protocol: protocol,
|
|
slashes: forwardSlashes || isSpecial(protocol),
|
|
slashesCount: slashesCount,
|
|
rest: rest
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Resolve a relative URL pathname against a base URL pathname.
|
|
*
|
|
* @param {String} relative Pathname of the relative URL.
|
|
* @param {String} base Pathname of the base URL.
|
|
* @return {String} Resolved pathname.
|
|
* @private
|
|
*/
|
|
function resolve(relative, base) {
|
|
if (relative === '') return base;
|
|
|
|
var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/'))
|
|
, i = path.length
|
|
, last = path[i - 1]
|
|
, unshift = false
|
|
, up = 0;
|
|
|
|
while (i--) {
|
|
if (path[i] === '.') {
|
|
path.splice(i, 1);
|
|
} else if (path[i] === '..') {
|
|
path.splice(i, 1);
|
|
up++;
|
|
} else if (up) {
|
|
if (i === 0) unshift = true;
|
|
path.splice(i, 1);
|
|
up--;
|
|
}
|
|
}
|
|
|
|
if (unshift) path.unshift('');
|
|
if (last === '.' || last === '..') path.push('');
|
|
|
|
return path.join('/');
|
|
}
|
|
|
|
/**
|
|
* The actual URL instance. Instead of returning an object we've opted-in to
|
|
* create an actual constructor as it's much more memory efficient and
|
|
* faster and it pleases my OCD.
|
|
*
|
|
* It is worth noting that we should not use `URL` as class name to prevent
|
|
* clashes with the global URL instance that got introduced in browsers.
|
|
*
|
|
* @constructor
|
|
* @param {String} address URL we want to parse.
|
|
* @param {Object|String} [location] Location defaults for relative paths.
|
|
* @param {Boolean|Function} [parser] Parser for the query string.
|
|
* @private
|
|
*/
|
|
function Url(address, location, parser) {
|
|
address = trimLeft(address);
|
|
address = address.replace(CRHTLF, '');
|
|
|
|
if (!(this instanceof Url)) {
|
|
return new Url(address, location, parser);
|
|
}
|
|
|
|
var relative, extracted, parse, instruction, index, key
|
|
, instructions = rules.slice()
|
|
, type = typeof location
|
|
, url = this
|
|
, i = 0;
|
|
|
|
//
|
|
// The following if statements allows this module two have compatibility with
|
|
// 2 different API:
|
|
//
|
|
// 1. Node.js's `url.parse` api which accepts a URL, boolean as arguments
|
|
// where the boolean indicates that the query string should also be parsed.
|
|
//
|
|
// 2. The `URL` interface of the browser which accepts a URL, object as
|
|
// arguments. The supplied object will be used as default values / fall-back
|
|
// for relative paths.
|
|
//
|
|
if ('object' !== type && 'string' !== type) {
|
|
parser = location;
|
|
location = null;
|
|
}
|
|
|
|
if (parser && 'function' !== typeof parser) parser = qs.parse;
|
|
|
|
location = lolcation(location);
|
|
|
|
//
|
|
// Extract protocol information before running the instructions.
|
|
//
|
|
extracted = extractProtocol(address || '', location);
|
|
relative = !extracted.protocol && !extracted.slashes;
|
|
url.slashes = extracted.slashes || relative && location.slashes;
|
|
url.protocol = extracted.protocol || location.protocol || '';
|
|
address = extracted.rest;
|
|
|
|
//
|
|
// When the authority component is absent the URL starts with a path
|
|
// component.
|
|
//
|
|
if (
|
|
extracted.protocol === 'file:' && (
|
|
extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) ||
|
|
(!extracted.slashes &&
|
|
(extracted.protocol ||
|
|
extracted.slashesCount < 2 ||
|
|
!isSpecial(url.protocol)))
|
|
) {
|
|
instructions[3] = [/(.*)/, 'pathname'];
|
|
}
|
|
|
|
for (; i < instructions.length; i++) {
|
|
instruction = instructions[i];
|
|
|
|
if (typeof instruction === 'function') {
|
|
address = instruction(address, url);
|
|
continue;
|
|
}
|
|
|
|
parse = instruction[0];
|
|
key = instruction[1];
|
|
|
|
if (parse !== parse) {
|
|
url[key] = address;
|
|
} else if ('string' === typeof parse) {
|
|
index = parse === '@'
|
|
? address.lastIndexOf(parse)
|
|
: address.indexOf(parse);
|
|
|
|
if (~index) {
|
|
if ('number' === typeof instruction[2]) {
|
|
url[key] = address.slice(0, index);
|
|
address = address.slice(index + instruction[2]);
|
|
} else {
|
|
url[key] = address.slice(index);
|
|
address = address.slice(0, index);
|
|
}
|
|
}
|
|
} else if ((index = parse.exec(address))) {
|
|
url[key] = index[1];
|
|
address = address.slice(0, index.index);
|
|
}
|
|
|
|
url[key] = url[key] || (
|
|
relative && instruction[3] ? location[key] || '' : ''
|
|
);
|
|
|
|
//
|
|
// Hostname, host and protocol should be lowercased so they can be used to
|
|
// create a proper `origin`.
|
|
//
|
|
if (instruction[4]) url[key] = url[key].toLowerCase();
|
|
}
|
|
|
|
//
|
|
// Also parse the supplied query string in to an object. If we're supplied
|
|
// with a custom parser as function use that instead of the default build-in
|
|
// parser.
|
|
//
|
|
if (parser) url.query = parser(url.query);
|
|
|
|
//
|
|
// If the URL is relative, resolve the pathname against the base URL.
|
|
//
|
|
if (
|
|
relative
|
|
&& location.slashes
|
|
&& url.pathname.charAt(0) !== '/'
|
|
&& (url.pathname !== '' || location.pathname !== '')
|
|
) {
|
|
url.pathname = resolve(url.pathname, location.pathname);
|
|
}
|
|
|
|
//
|
|
// Default to a / for pathname if none exists. This normalizes the URL
|
|
// to always have a /
|
|
//
|
|
if (url.pathname.charAt(0) !== '/' && isSpecial(url.protocol)) {
|
|
url.pathname = '/' + url.pathname;
|
|
}
|
|
|
|
//
|
|
// We should not add port numbers if they are already the default port number
|
|
// for a given protocol. As the host also contains the port number we're going
|
|
// override it with the hostname which contains no port number.
|
|
//
|
|
if (!required(url.port, url.protocol)) {
|
|
url.host = url.hostname;
|
|
url.port = '';
|
|
}
|
|
|
|
//
|
|
// Parse down the `auth` for the username and password.
|
|
//
|
|
url.username = url.password = '';
|
|
|
|
if (url.auth) {
|
|
index = url.auth.indexOf(':');
|
|
|
|
if (~index) {
|
|
url.username = url.auth.slice(0, index);
|
|
url.username = encodeURIComponent(decodeURIComponent(url.username));
|
|
|
|
url.password = url.auth.slice(index + 1);
|
|
url.password = encodeURIComponent(decodeURIComponent(url.password))
|
|
} else {
|
|
url.username = encodeURIComponent(decodeURIComponent(url.auth));
|
|
}
|
|
|
|
url.auth = url.password ? url.username +':'+ url.password : url.username;
|
|
}
|
|
|
|
url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host
|
|
? url.protocol +'//'+ url.host
|
|
: 'null';
|
|
|
|
//
|
|
// The href is just the compiled result.
|
|
//
|
|
url.href = url.toString();
|
|
}
|
|
|
|
/**
|
|
* This is convenience method for changing properties in the URL instance to
|
|
* insure that they all propagate correctly.
|
|
*
|
|
* @param {String} part Property we need to adjust.
|
|
* @param {Mixed} value The newly assigned value.
|
|
* @param {Boolean|Function} fn When setting the query, it will be the function
|
|
* used to parse the query.
|
|
* When setting the protocol, double slash will be
|
|
* removed from the final url if it is true.
|
|
* @returns {URL} URL instance for chaining.
|
|
* @public
|
|
*/
|
|
function set(part, value, fn) {
|
|
var url = this;
|
|
|
|
switch (part) {
|
|
case 'query':
|
|
if ('string' === typeof value && value.length) {
|
|
value = (fn || qs.parse)(value);
|
|
}
|
|
|
|
url[part] = value;
|
|
break;
|
|
|
|
case 'port':
|
|
url[part] = value;
|
|
|
|
if (!required(value, url.protocol)) {
|
|
url.host = url.hostname;
|
|
url[part] = '';
|
|
} else if (value) {
|
|
url.host = url.hostname +':'+ value;
|
|
}
|
|
|
|
break;
|
|
|
|
case 'hostname':
|
|
url[part] = value;
|
|
|
|
if (url.port) value += ':'+ url.port;
|
|
url.host = value;
|
|
break;
|
|
|
|
case 'host':
|
|
url[part] = value;
|
|
|
|
if (port.test(value)) {
|
|
value = value.split(':');
|
|
url.port = value.pop();
|
|
url.hostname = value.join(':');
|
|
} else {
|
|
url.hostname = value;
|
|
url.port = '';
|
|
}
|
|
|
|
break;
|
|
|
|
case 'protocol':
|
|
url.protocol = value.toLowerCase();
|
|
url.slashes = !fn;
|
|
break;
|
|
|
|
case 'pathname':
|
|
case 'hash':
|
|
if (value) {
|
|
var char = part === 'pathname' ? '/' : '#';
|
|
url[part] = value.charAt(0) !== char ? char + value : value;
|
|
} else {
|
|
url[part] = value;
|
|
}
|
|
break;
|
|
|
|
case 'username':
|
|
case 'password':
|
|
url[part] = encodeURIComponent(value);
|
|
break;
|
|
|
|
case 'auth':
|
|
var index = value.indexOf(':');
|
|
|
|
if (~index) {
|
|
url.username = value.slice(0, index);
|
|
url.username = encodeURIComponent(decodeURIComponent(url.username));
|
|
|
|
url.password = value.slice(index + 1);
|
|
url.password = encodeURIComponent(decodeURIComponent(url.password));
|
|
} else {
|
|
url.username = encodeURIComponent(decodeURIComponent(value));
|
|
}
|
|
}
|
|
|
|
for (var i = 0; i < rules.length; i++) {
|
|
var ins = rules[i];
|
|
|
|
if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();
|
|
}
|
|
|
|
url.auth = url.password ? url.username +':'+ url.password : url.username;
|
|
|
|
url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host
|
|
? url.protocol +'//'+ url.host
|
|
: 'null';
|
|
|
|
url.href = url.toString();
|
|
|
|
return url;
|
|
}
|
|
|
|
/**
|
|
* Transform the properties back in to a valid and full URL string.
|
|
*
|
|
* @param {Function} stringify Optional query stringify function.
|
|
* @returns {String} Compiled version of the URL.
|
|
* @public
|
|
*/
|
|
function toString(stringify) {
|
|
if (!stringify || 'function' !== typeof stringify) stringify = qs.stringify;
|
|
|
|
var query
|
|
, url = this
|
|
, host = url.host
|
|
, protocol = url.protocol;
|
|
|
|
if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':';
|
|
|
|
var result =
|
|
protocol +
|
|
((url.protocol && url.slashes) || isSpecial(url.protocol) ? '//' : '');
|
|
|
|
if (url.username) {
|
|
result += url.username;
|
|
if (url.password) result += ':'+ url.password;
|
|
result += '@';
|
|
} else if (url.password) {
|
|
result += ':'+ url.password;
|
|
result += '@';
|
|
} else if (
|
|
url.protocol !== 'file:' &&
|
|
isSpecial(url.protocol) &&
|
|
!host &&
|
|
url.pathname !== '/'
|
|
) {
|
|
//
|
|
// Add back the empty userinfo, otherwise the original invalid URL
|
|
// might be transformed into a valid one with `url.pathname` as host.
|
|
//
|
|
result += '@';
|
|
}
|
|
|
|
//
|
|
// Trailing colon is removed from `url.host` when it is parsed. If it still
|
|
// ends with a colon, then add back the trailing colon that was removed. This
|
|
// prevents an invalid URL from being transformed into a valid one.
|
|
//
|
|
if (host[host.length - 1] === ':' || (port.test(url.hostname) && !url.port)) {
|
|
host += ':';
|
|
}
|
|
|
|
result += host + url.pathname;
|
|
|
|
query = 'object' === typeof url.query ? stringify(url.query) : url.query;
|
|
if (query) result += '?' !== query.charAt(0) ? '?'+ query : query;
|
|
|
|
if (url.hash) result += url.hash;
|
|
|
|
return result;
|
|
}
|
|
|
|
Url.prototype = { set: set, toString: toString };
|
|
|
|
//
|
|
// Expose the URL parser and some additional properties that might be useful for
|
|
// others or testing.
|
|
//
|
|
Url.extractProtocol = extractProtocol;
|
|
Url.location = lolcation;
|
|
Url.trimLeft = trimLeft;
|
|
Url.qs = qs;
|
|
|
|
module.exports = Url;
|
|
|
|
|
|
/***/ })
|
|
|
|
}]);
|
|
//# sourceMappingURL=383.086fc5ebac8a08e85b7c.js.map?v=086fc5ebac8a08e85b7c
|