sanitize-html 1.16.3 → 1.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.travis.yml +5 -0
- package/README.md +98 -2
- package/dist/index.js +106 -9
- package/dist/sanitize-html.js +1878 -75
- package/dist/sanitize-html.min.js +12 -12
- package/package.json +6 -3
- package/src/index.js +68 -13
- package/test/test.js +75 -0
package/dist/sanitize-html.js
CHANGED
|
@@ -6,8 +6,11 @@ var extend = require('xtend');
|
|
|
6
6
|
var quoteRegexp = require('lodash.escaperegexp');
|
|
7
7
|
var cloneDeep = require('lodash.clonedeep');
|
|
8
8
|
var mergeWith = require('lodash.mergewith');
|
|
9
|
+
var isString = require('lodash.isstring');
|
|
10
|
+
var isPlainObject = require('lodash.isplainobject');
|
|
9
11
|
var srcset = require('srcset');
|
|
10
12
|
var postcss = require('postcss');
|
|
13
|
+
var url = require('url');
|
|
11
14
|
|
|
12
15
|
function each(obj, cb) {
|
|
13
16
|
if (obj) Object.keys(obj).forEach(function (key) {
|
|
@@ -93,11 +96,11 @@ function sanitizeHtml(html, options, _recursing) {
|
|
|
93
96
|
each(options.allowedAttributes, function (attributes, tag) {
|
|
94
97
|
allowedAttributesMap[tag] = [];
|
|
95
98
|
var globRegex = [];
|
|
96
|
-
attributes.forEach(function (
|
|
97
|
-
if (
|
|
98
|
-
globRegex.push(quoteRegexp(
|
|
99
|
+
attributes.forEach(function (obj) {
|
|
100
|
+
if (isString(obj) && obj.indexOf('*') >= 0) {
|
|
101
|
+
globRegex.push(quoteRegexp(obj).replace(/\\\*/g, '.*'));
|
|
99
102
|
} else {
|
|
100
|
-
allowedAttributesMap[tag].push(
|
|
103
|
+
allowedAttributesMap[tag].push(obj);
|
|
101
104
|
}
|
|
102
105
|
});
|
|
103
106
|
allowedAttributesGlobMap[tag] = new RegExp('^(' + globRegex.join('|') + ')$');
|
|
@@ -198,17 +201,111 @@ function sanitizeHtml(html, options, _recursing) {
|
|
|
198
201
|
return;
|
|
199
202
|
}
|
|
200
203
|
var parsed;
|
|
204
|
+
// check allowedAttributesMap for the element and attribute and modify the value
|
|
205
|
+
// as necessary if there are specific values defined.
|
|
206
|
+
var passedAllowedAttributesMapCheck = false;
|
|
201
207
|
if (!allowedAttributesMap || has(allowedAttributesMap, name) && allowedAttributesMap[name].indexOf(a) !== -1 || allowedAttributesMap['*'] && allowedAttributesMap['*'].indexOf(a) !== -1 || has(allowedAttributesGlobMap, name) && allowedAttributesGlobMap[name].test(a) || allowedAttributesGlobMap['*'] && allowedAttributesGlobMap['*'].test(a)) {
|
|
202
|
-
|
|
208
|
+
passedAllowedAttributesMapCheck = true;
|
|
209
|
+
} else if (allowedAttributesMap && allowedAttributesMap[name]) {
|
|
210
|
+
var _iteratorNormalCompletion = true;
|
|
211
|
+
var _didIteratorError = false;
|
|
212
|
+
var _iteratorError = undefined;
|
|
213
|
+
|
|
214
|
+
try {
|
|
215
|
+
for (var _iterator = allowedAttributesMap[name][Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
216
|
+
var o = _step.value;
|
|
217
|
+
|
|
218
|
+
if (isPlainObject(o) && o.name && o.name === a) {
|
|
219
|
+
passedAllowedAttributesMapCheck = true;
|
|
220
|
+
var newValue = '';
|
|
221
|
+
if (o.multiple === true) {
|
|
222
|
+
// verify the values that are allowed
|
|
223
|
+
var splitStrArray = value.split(' ');
|
|
224
|
+
var _iteratorNormalCompletion2 = true;
|
|
225
|
+
var _didIteratorError2 = false;
|
|
226
|
+
var _iteratorError2 = undefined;
|
|
227
|
+
|
|
228
|
+
try {
|
|
229
|
+
for (var _iterator2 = splitStrArray[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
230
|
+
var s = _step2.value;
|
|
231
|
+
|
|
232
|
+
if (o.values.indexOf(s) !== -1) {
|
|
233
|
+
if (newValue === '') {
|
|
234
|
+
newValue = s;
|
|
235
|
+
} else {
|
|
236
|
+
newValue += ' ' + s;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
} catch (err) {
|
|
241
|
+
_didIteratorError2 = true;
|
|
242
|
+
_iteratorError2 = err;
|
|
243
|
+
} finally {
|
|
244
|
+
try {
|
|
245
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
|
246
|
+
_iterator2.return();
|
|
247
|
+
}
|
|
248
|
+
} finally {
|
|
249
|
+
if (_didIteratorError2) {
|
|
250
|
+
throw _iteratorError2;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
} else if (o.values.indexOf(value) >= 0) {
|
|
255
|
+
// verified an allowed value matches the entire attribute value
|
|
256
|
+
newValue = value;
|
|
257
|
+
}
|
|
258
|
+
value = newValue;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
} catch (err) {
|
|
262
|
+
_didIteratorError = true;
|
|
263
|
+
_iteratorError = err;
|
|
264
|
+
} finally {
|
|
265
|
+
try {
|
|
266
|
+
if (!_iteratorNormalCompletion && _iterator.return) {
|
|
267
|
+
_iterator.return();
|
|
268
|
+
}
|
|
269
|
+
} finally {
|
|
270
|
+
if (_didIteratorError) {
|
|
271
|
+
throw _iteratorError;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (passedAllowedAttributesMapCheck) {
|
|
277
|
+
if (options.allowedSchemesAppliedToAttributes.indexOf(a) !== -1) {
|
|
203
278
|
if (naughtyHref(name, value)) {
|
|
204
279
|
delete frame.attribs[a];
|
|
205
280
|
return;
|
|
206
281
|
}
|
|
207
282
|
}
|
|
208
|
-
|
|
283
|
+
if (name === 'iframe' && a === 'src') {
|
|
284
|
+
//Check if value contains proper hostname prefix
|
|
285
|
+
if (value.substring(0, 2) === '//') {
|
|
286
|
+
var prefix = 'https:';
|
|
287
|
+
value = prefix.concat(value);
|
|
288
|
+
}
|
|
289
|
+
try {
|
|
290
|
+
parsed = url.parse(value);
|
|
291
|
+
if (options.allowedIframeHostnames) {
|
|
292
|
+
var whitelistedHostnames = options.allowedIframeHostnames.find(function (hostname) {
|
|
293
|
+
return hostname === parsed.hostname;
|
|
294
|
+
});
|
|
295
|
+
if (!whitelistedHostnames) {
|
|
296
|
+
delete frame.attribs[a];
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
} catch (e) {
|
|
301
|
+
// Unparseable iframe src
|
|
302
|
+
delete frame.attribs[a];
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
209
306
|
if (a === 'srcset') {
|
|
210
307
|
try {
|
|
211
|
-
|
|
308
|
+
parsed = srcset.parse(value);
|
|
212
309
|
each(parsed, function (value) {
|
|
213
310
|
if (naughtyHref('srcset', value.url)) {
|
|
214
311
|
value.evil = true;
|
|
@@ -232,7 +329,6 @@ function sanitizeHtml(html, options, _recursing) {
|
|
|
232
329
|
return;
|
|
233
330
|
}
|
|
234
331
|
}
|
|
235
|
-
|
|
236
332
|
if (a === 'class') {
|
|
237
333
|
value = filterClasses(value, allowedClassesMap[name]);
|
|
238
334
|
if (!value.length) {
|
|
@@ -487,7 +583,7 @@ var htmlParserDefaults = {
|
|
|
487
583
|
decodeEntities: true
|
|
488
584
|
};
|
|
489
585
|
sanitizeHtml.defaults = {
|
|
490
|
-
allowedTags: ['h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a', 'ul', 'ol', 'nl', 'li', 'b', 'i', 'strong', 'em', 'strike', 'code', 'hr', 'br', 'div', 'table', 'thead', 'caption', 'tbody', 'tr', 'th', 'td', 'pre'],
|
|
586
|
+
allowedTags: ['h3', 'h4', 'h5', 'h6', 'blockquote', 'p', 'a', 'ul', 'ol', 'nl', 'li', 'b', 'i', 'strong', 'em', 'strike', 'code', 'hr', 'br', 'div', 'table', 'thead', 'caption', 'tbody', 'tr', 'th', 'td', 'pre', 'iframe'],
|
|
491
587
|
allowedAttributes: {
|
|
492
588
|
a: ['href', 'name', 'target'],
|
|
493
589
|
// We don't currently allow img itself by default, but this
|
|
@@ -500,6 +596,7 @@ sanitizeHtml.defaults = {
|
|
|
500
596
|
// URL schemes we permit
|
|
501
597
|
allowedSchemes: ['http', 'https', 'ftp', 'mailto'],
|
|
502
598
|
allowedSchemesByTag: {},
|
|
599
|
+
allowedSchemesAppliedToAttributes: ['href', 'src', 'cite'],
|
|
503
600
|
allowProtocolRelative: true
|
|
504
601
|
};
|
|
505
602
|
|
|
@@ -523,7 +620,7 @@ sanitizeHtml.simpleTransform = function (newTagName, newAttribs, merge) {
|
|
|
523
620
|
};
|
|
524
621
|
};
|
|
525
622
|
};
|
|
526
|
-
},{"htmlparser2":36,"lodash.clonedeep":41,"lodash.escaperegexp":42,"lodash.
|
|
623
|
+
},{"htmlparser2":36,"lodash.clonedeep":41,"lodash.escaperegexp":42,"lodash.isplainobject":43,"lodash.isstring":44,"lodash.mergewith":45,"postcss":60,"srcset":91,"url":109,"xtend":112}],2:[function(require,module,exports){
|
|
527
624
|
(function (global){
|
|
528
625
|
'use strict';
|
|
529
626
|
|
|
@@ -5620,7 +5717,7 @@ WritableStream.prototype._write = function(chunk, encoding, cb){
|
|
|
5620
5717
|
this._parser.write(chunk);
|
|
5621
5718
|
cb();
|
|
5622
5719
|
};
|
|
5623
|
-
},{"./Parser.js":31,"buffer":5,"inherits":38,"readable-stream":4,"stream":
|
|
5720
|
+
},{"./Parser.js":31,"buffer":5,"inherits":38,"readable-stream":4,"stream":92,"string_decoder":108}],36:[function(require,module,exports){
|
|
5624
5721
|
var Parser = require("./Parser.js"),
|
|
5625
5722
|
DomHandler = require("domhandler");
|
|
5626
5723
|
|
|
@@ -7754,6 +7851,244 @@ module.exports = escapeRegExp;
|
|
|
7754
7851
|
|
|
7755
7852
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
7756
7853
|
},{}],43:[function(require,module,exports){
|
|
7854
|
+
/**
|
|
7855
|
+
* lodash (Custom Build) <https://lodash.com/>
|
|
7856
|
+
* Build: `lodash modularize exports="npm" -o ./`
|
|
7857
|
+
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
|
7858
|
+
* Released under MIT license <https://lodash.com/license>
|
|
7859
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
7860
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
7861
|
+
*/
|
|
7862
|
+
|
|
7863
|
+
/** `Object#toString` result references. */
|
|
7864
|
+
var objectTag = '[object Object]';
|
|
7865
|
+
|
|
7866
|
+
/**
|
|
7867
|
+
* Checks if `value` is a host object in IE < 9.
|
|
7868
|
+
*
|
|
7869
|
+
* @private
|
|
7870
|
+
* @param {*} value The value to check.
|
|
7871
|
+
* @returns {boolean} Returns `true` if `value` is a host object, else `false`.
|
|
7872
|
+
*/
|
|
7873
|
+
function isHostObject(value) {
|
|
7874
|
+
// Many host objects are `Object` objects that can coerce to strings
|
|
7875
|
+
// despite having improperly defined `toString` methods.
|
|
7876
|
+
var result = false;
|
|
7877
|
+
if (value != null && typeof value.toString != 'function') {
|
|
7878
|
+
try {
|
|
7879
|
+
result = !!(value + '');
|
|
7880
|
+
} catch (e) {}
|
|
7881
|
+
}
|
|
7882
|
+
return result;
|
|
7883
|
+
}
|
|
7884
|
+
|
|
7885
|
+
/**
|
|
7886
|
+
* Creates a unary function that invokes `func` with its argument transformed.
|
|
7887
|
+
*
|
|
7888
|
+
* @private
|
|
7889
|
+
* @param {Function} func The function to wrap.
|
|
7890
|
+
* @param {Function} transform The argument transform.
|
|
7891
|
+
* @returns {Function} Returns the new function.
|
|
7892
|
+
*/
|
|
7893
|
+
function overArg(func, transform) {
|
|
7894
|
+
return function(arg) {
|
|
7895
|
+
return func(transform(arg));
|
|
7896
|
+
};
|
|
7897
|
+
}
|
|
7898
|
+
|
|
7899
|
+
/** Used for built-in method references. */
|
|
7900
|
+
var funcProto = Function.prototype,
|
|
7901
|
+
objectProto = Object.prototype;
|
|
7902
|
+
|
|
7903
|
+
/** Used to resolve the decompiled source of functions. */
|
|
7904
|
+
var funcToString = funcProto.toString;
|
|
7905
|
+
|
|
7906
|
+
/** Used to check objects for own properties. */
|
|
7907
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
7908
|
+
|
|
7909
|
+
/** Used to infer the `Object` constructor. */
|
|
7910
|
+
var objectCtorString = funcToString.call(Object);
|
|
7911
|
+
|
|
7912
|
+
/**
|
|
7913
|
+
* Used to resolve the
|
|
7914
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
7915
|
+
* of values.
|
|
7916
|
+
*/
|
|
7917
|
+
var objectToString = objectProto.toString;
|
|
7918
|
+
|
|
7919
|
+
/** Built-in value references. */
|
|
7920
|
+
var getPrototype = overArg(Object.getPrototypeOf, Object);
|
|
7921
|
+
|
|
7922
|
+
/**
|
|
7923
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
7924
|
+
* and has a `typeof` result of "object".
|
|
7925
|
+
*
|
|
7926
|
+
* @static
|
|
7927
|
+
* @memberOf _
|
|
7928
|
+
* @since 4.0.0
|
|
7929
|
+
* @category Lang
|
|
7930
|
+
* @param {*} value The value to check.
|
|
7931
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
7932
|
+
* @example
|
|
7933
|
+
*
|
|
7934
|
+
* _.isObjectLike({});
|
|
7935
|
+
* // => true
|
|
7936
|
+
*
|
|
7937
|
+
* _.isObjectLike([1, 2, 3]);
|
|
7938
|
+
* // => true
|
|
7939
|
+
*
|
|
7940
|
+
* _.isObjectLike(_.noop);
|
|
7941
|
+
* // => false
|
|
7942
|
+
*
|
|
7943
|
+
* _.isObjectLike(null);
|
|
7944
|
+
* // => false
|
|
7945
|
+
*/
|
|
7946
|
+
function isObjectLike(value) {
|
|
7947
|
+
return !!value && typeof value == 'object';
|
|
7948
|
+
}
|
|
7949
|
+
|
|
7950
|
+
/**
|
|
7951
|
+
* Checks if `value` is a plain object, that is, an object created by the
|
|
7952
|
+
* `Object` constructor or one with a `[[Prototype]]` of `null`.
|
|
7953
|
+
*
|
|
7954
|
+
* @static
|
|
7955
|
+
* @memberOf _
|
|
7956
|
+
* @since 0.8.0
|
|
7957
|
+
* @category Lang
|
|
7958
|
+
* @param {*} value The value to check.
|
|
7959
|
+
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
|
|
7960
|
+
* @example
|
|
7961
|
+
*
|
|
7962
|
+
* function Foo() {
|
|
7963
|
+
* this.a = 1;
|
|
7964
|
+
* }
|
|
7965
|
+
*
|
|
7966
|
+
* _.isPlainObject(new Foo);
|
|
7967
|
+
* // => false
|
|
7968
|
+
*
|
|
7969
|
+
* _.isPlainObject([1, 2, 3]);
|
|
7970
|
+
* // => false
|
|
7971
|
+
*
|
|
7972
|
+
* _.isPlainObject({ 'x': 0, 'y': 0 });
|
|
7973
|
+
* // => true
|
|
7974
|
+
*
|
|
7975
|
+
* _.isPlainObject(Object.create(null));
|
|
7976
|
+
* // => true
|
|
7977
|
+
*/
|
|
7978
|
+
function isPlainObject(value) {
|
|
7979
|
+
if (!isObjectLike(value) ||
|
|
7980
|
+
objectToString.call(value) != objectTag || isHostObject(value)) {
|
|
7981
|
+
return false;
|
|
7982
|
+
}
|
|
7983
|
+
var proto = getPrototype(value);
|
|
7984
|
+
if (proto === null) {
|
|
7985
|
+
return true;
|
|
7986
|
+
}
|
|
7987
|
+
var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
|
|
7988
|
+
return (typeof Ctor == 'function' &&
|
|
7989
|
+
Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString);
|
|
7990
|
+
}
|
|
7991
|
+
|
|
7992
|
+
module.exports = isPlainObject;
|
|
7993
|
+
|
|
7994
|
+
},{}],44:[function(require,module,exports){
|
|
7995
|
+
/**
|
|
7996
|
+
* lodash 4.0.1 (Custom Build) <https://lodash.com/>
|
|
7997
|
+
* Build: `lodash modularize exports="npm" -o ./`
|
|
7998
|
+
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
|
|
7999
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
8000
|
+
* Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
8001
|
+
* Available under MIT license <https://lodash.com/license>
|
|
8002
|
+
*/
|
|
8003
|
+
|
|
8004
|
+
/** `Object#toString` result references. */
|
|
8005
|
+
var stringTag = '[object String]';
|
|
8006
|
+
|
|
8007
|
+
/** Used for built-in method references. */
|
|
8008
|
+
var objectProto = Object.prototype;
|
|
8009
|
+
|
|
8010
|
+
/**
|
|
8011
|
+
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
|
|
8012
|
+
* of values.
|
|
8013
|
+
*/
|
|
8014
|
+
var objectToString = objectProto.toString;
|
|
8015
|
+
|
|
8016
|
+
/**
|
|
8017
|
+
* Checks if `value` is classified as an `Array` object.
|
|
8018
|
+
*
|
|
8019
|
+
* @static
|
|
8020
|
+
* @memberOf _
|
|
8021
|
+
* @type Function
|
|
8022
|
+
* @category Lang
|
|
8023
|
+
* @param {*} value The value to check.
|
|
8024
|
+
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
|
8025
|
+
* @example
|
|
8026
|
+
*
|
|
8027
|
+
* _.isArray([1, 2, 3]);
|
|
8028
|
+
* // => true
|
|
8029
|
+
*
|
|
8030
|
+
* _.isArray(document.body.children);
|
|
8031
|
+
* // => false
|
|
8032
|
+
*
|
|
8033
|
+
* _.isArray('abc');
|
|
8034
|
+
* // => false
|
|
8035
|
+
*
|
|
8036
|
+
* _.isArray(_.noop);
|
|
8037
|
+
* // => false
|
|
8038
|
+
*/
|
|
8039
|
+
var isArray = Array.isArray;
|
|
8040
|
+
|
|
8041
|
+
/**
|
|
8042
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
8043
|
+
* and has a `typeof` result of "object".
|
|
8044
|
+
*
|
|
8045
|
+
* @static
|
|
8046
|
+
* @memberOf _
|
|
8047
|
+
* @category Lang
|
|
8048
|
+
* @param {*} value The value to check.
|
|
8049
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
8050
|
+
* @example
|
|
8051
|
+
*
|
|
8052
|
+
* _.isObjectLike({});
|
|
8053
|
+
* // => true
|
|
8054
|
+
*
|
|
8055
|
+
* _.isObjectLike([1, 2, 3]);
|
|
8056
|
+
* // => true
|
|
8057
|
+
*
|
|
8058
|
+
* _.isObjectLike(_.noop);
|
|
8059
|
+
* // => false
|
|
8060
|
+
*
|
|
8061
|
+
* _.isObjectLike(null);
|
|
8062
|
+
* // => false
|
|
8063
|
+
*/
|
|
8064
|
+
function isObjectLike(value) {
|
|
8065
|
+
return !!value && typeof value == 'object';
|
|
8066
|
+
}
|
|
8067
|
+
|
|
8068
|
+
/**
|
|
8069
|
+
* Checks if `value` is classified as a `String` primitive or object.
|
|
8070
|
+
*
|
|
8071
|
+
* @static
|
|
8072
|
+
* @memberOf _
|
|
8073
|
+
* @category Lang
|
|
8074
|
+
* @param {*} value The value to check.
|
|
8075
|
+
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
|
|
8076
|
+
* @example
|
|
8077
|
+
*
|
|
8078
|
+
* _.isString('abc');
|
|
8079
|
+
* // => true
|
|
8080
|
+
*
|
|
8081
|
+
* _.isString(1);
|
|
8082
|
+
* // => false
|
|
8083
|
+
*/
|
|
8084
|
+
function isString(value) {
|
|
8085
|
+
return typeof value == 'string' ||
|
|
8086
|
+
(!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag);
|
|
8087
|
+
}
|
|
8088
|
+
|
|
8089
|
+
module.exports = isString;
|
|
8090
|
+
|
|
8091
|
+
},{}],45:[function(require,module,exports){
|
|
7757
8092
|
(function (global){
|
|
7758
8093
|
/**
|
|
7759
8094
|
* lodash (Custom Build) <https://lodash.com/>
|
|
@@ -9964,13 +10299,13 @@ function stubFalse() {
|
|
|
9964
10299
|
module.exports = mergeWith;
|
|
9965
10300
|
|
|
9966
10301
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
9967
|
-
},{}],
|
|
10302
|
+
},{}],46:[function(require,module,exports){
|
|
9968
10303
|
'use strict';
|
|
9969
10304
|
module.exports = Number.isNaN || function (x) {
|
|
9970
10305
|
return x !== x;
|
|
9971
10306
|
};
|
|
9972
10307
|
|
|
9973
|
-
},{}],
|
|
10308
|
+
},{}],47:[function(require,module,exports){
|
|
9974
10309
|
(function (process){
|
|
9975
10310
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
9976
10311
|
//
|
|
@@ -10198,7 +10533,7 @@ var substr = 'ab'.substr(-1) === 'b'
|
|
|
10198
10533
|
;
|
|
10199
10534
|
|
|
10200
10535
|
}).call(this,require('_process'))
|
|
10201
|
-
},{"_process":
|
|
10536
|
+
},{"_process":85}],48:[function(require,module,exports){
|
|
10202
10537
|
'use strict';
|
|
10203
10538
|
|
|
10204
10539
|
exports.__esModule = true;
|
|
@@ -10331,7 +10666,7 @@ exports.default = AtRule;
|
|
|
10331
10666
|
module.exports = exports['default'];
|
|
10332
10667
|
|
|
10333
10668
|
|
|
10334
|
-
},{"./container":
|
|
10669
|
+
},{"./container":50}],49:[function(require,module,exports){
|
|
10335
10670
|
'use strict';
|
|
10336
10671
|
|
|
10337
10672
|
exports.__esModule = true;
|
|
@@ -10394,7 +10729,7 @@ exports.default = Comment;
|
|
|
10394
10729
|
module.exports = exports['default'];
|
|
10395
10730
|
|
|
10396
10731
|
|
|
10397
|
-
},{"./node":
|
|
10732
|
+
},{"./node":57}],50:[function(require,module,exports){
|
|
10398
10733
|
'use strict';
|
|
10399
10734
|
|
|
10400
10735
|
exports.__esModule = true;
|
|
@@ -11303,7 +11638,7 @@ exports.default = Container;
|
|
|
11303
11638
|
module.exports = exports['default'];
|
|
11304
11639
|
|
|
11305
11640
|
|
|
11306
|
-
},{"./at-rule":
|
|
11641
|
+
},{"./at-rule":48,"./comment":49,"./declaration":52,"./node":57,"./parse":58,"./root":64,"./rule":65}],51:[function(require,module,exports){
|
|
11307
11642
|
'use strict';
|
|
11308
11643
|
|
|
11309
11644
|
exports.__esModule = true;
|
|
@@ -11561,7 +11896,7 @@ exports.default = CssSyntaxError;
|
|
|
11561
11896
|
module.exports = exports['default'];
|
|
11562
11897
|
|
|
11563
11898
|
|
|
11564
|
-
},{"./terminal-highlight":
|
|
11899
|
+
},{"./terminal-highlight":68,"chalk":4,"supports-color":4}],52:[function(require,module,exports){
|
|
11565
11900
|
'use strict';
|
|
11566
11901
|
|
|
11567
11902
|
exports.__esModule = true;
|
|
@@ -11664,7 +11999,7 @@ exports.default = Declaration;
|
|
|
11664
11999
|
module.exports = exports['default'];
|
|
11665
12000
|
|
|
11666
12001
|
|
|
11667
|
-
},{"./node":
|
|
12002
|
+
},{"./node":57}],53:[function(require,module,exports){
|
|
11668
12003
|
'use strict';
|
|
11669
12004
|
|
|
11670
12005
|
exports.__esModule = true;
|
|
@@ -11864,7 +12199,7 @@ exports.default = Input;
|
|
|
11864
12199
|
module.exports = exports['default'];
|
|
11865
12200
|
|
|
11866
12201
|
|
|
11867
|
-
},{"./css-syntax-error":
|
|
12202
|
+
},{"./css-syntax-error":51,"./previous-map":61,"path":47}],54:[function(require,module,exports){
|
|
11868
12203
|
'use strict';
|
|
11869
12204
|
|
|
11870
12205
|
exports.__esModule = true;
|
|
@@ -12294,7 +12629,7 @@ exports.default = LazyResult;
|
|
|
12294
12629
|
module.exports = exports['default'];
|
|
12295
12630
|
|
|
12296
12631
|
|
|
12297
|
-
},{"./map-generator":
|
|
12632
|
+
},{"./map-generator":56,"./parse":58,"./result":63,"./stringify":67}],55:[function(require,module,exports){
|
|
12298
12633
|
'use strict';
|
|
12299
12634
|
|
|
12300
12635
|
exports.__esModule = true;
|
|
@@ -12391,7 +12726,7 @@ exports.default = list;
|
|
|
12391
12726
|
module.exports = exports['default'];
|
|
12392
12727
|
|
|
12393
12728
|
|
|
12394
|
-
},{}],
|
|
12729
|
+
},{}],56:[function(require,module,exports){
|
|
12395
12730
|
(function (Buffer){
|
|
12396
12731
|
'use strict';
|
|
12397
12732
|
|
|
@@ -12718,7 +13053,7 @@ module.exports = exports['default'];
|
|
|
12718
13053
|
|
|
12719
13054
|
|
|
12720
13055
|
}).call(this,require("buffer").Buffer)
|
|
12721
|
-
},{"buffer":5,"path":
|
|
13056
|
+
},{"buffer":5,"path":47,"source-map":83}],57:[function(require,module,exports){
|
|
12722
13057
|
'use strict';
|
|
12723
13058
|
|
|
12724
13059
|
exports.__esModule = true;
|
|
@@ -13343,7 +13678,7 @@ exports.default = Node;
|
|
|
13343
13678
|
module.exports = exports['default'];
|
|
13344
13679
|
|
|
13345
13680
|
|
|
13346
|
-
},{"./css-syntax-error":
|
|
13681
|
+
},{"./css-syntax-error":51,"./stringifier":66,"./stringify":67,"./warn-once":71}],58:[function(require,module,exports){
|
|
13347
13682
|
'use strict';
|
|
13348
13683
|
|
|
13349
13684
|
exports.__esModule = true;
|
|
@@ -13386,7 +13721,7 @@ function parse(css, opts) {
|
|
|
13386
13721
|
module.exports = exports['default'];
|
|
13387
13722
|
|
|
13388
13723
|
|
|
13389
|
-
},{"./input":
|
|
13724
|
+
},{"./input":53,"./parser":59}],59:[function(require,module,exports){
|
|
13390
13725
|
'use strict';
|
|
13391
13726
|
|
|
13392
13727
|
exports.__esModule = true;
|
|
@@ -13922,7 +14257,7 @@ exports.default = Parser;
|
|
|
13922
14257
|
module.exports = exports['default'];
|
|
13923
14258
|
|
|
13924
14259
|
|
|
13925
|
-
},{"./at-rule":
|
|
14260
|
+
},{"./at-rule":48,"./comment":49,"./declaration":52,"./root":64,"./rule":65,"./tokenize":69}],60:[function(require,module,exports){
|
|
13926
14261
|
'use strict';
|
|
13927
14262
|
|
|
13928
14263
|
exports.__esModule = true;
|
|
@@ -14216,7 +14551,7 @@ exports.default = postcss;
|
|
|
14216
14551
|
module.exports = exports['default'];
|
|
14217
14552
|
|
|
14218
14553
|
|
|
14219
|
-
},{"./at-rule":
|
|
14554
|
+
},{"./at-rule":48,"./comment":49,"./declaration":52,"./list":55,"./parse":58,"./processor":62,"./root":64,"./rule":65,"./stringify":67,"./vendor":70}],61:[function(require,module,exports){
|
|
14220
14555
|
(function (Buffer){
|
|
14221
14556
|
'use strict';
|
|
14222
14557
|
|
|
@@ -14390,7 +14725,7 @@ module.exports = exports['default'];
|
|
|
14390
14725
|
|
|
14391
14726
|
|
|
14392
14727
|
}).call(this,require("buffer").Buffer)
|
|
14393
|
-
},{"buffer":5,"fs":4,"path":
|
|
14728
|
+
},{"buffer":5,"fs":4,"path":47,"source-map":83}],62:[function(require,module,exports){
|
|
14394
14729
|
'use strict';
|
|
14395
14730
|
|
|
14396
14731
|
exports.__esModule = true;
|
|
@@ -14632,7 +14967,7 @@ exports.default = Processor;
|
|
|
14632
14967
|
module.exports = exports['default'];
|
|
14633
14968
|
|
|
14634
14969
|
|
|
14635
|
-
},{"./lazy-result":
|
|
14970
|
+
},{"./lazy-result":54}],63:[function(require,module,exports){
|
|
14636
14971
|
'use strict';
|
|
14637
14972
|
|
|
14638
14973
|
exports.__esModule = true;
|
|
@@ -14840,7 +15175,7 @@ exports.default = Result;
|
|
|
14840
15175
|
module.exports = exports['default'];
|
|
14841
15176
|
|
|
14842
15177
|
|
|
14843
|
-
},{"./warning":
|
|
15178
|
+
},{"./warning":72}],64:[function(require,module,exports){
|
|
14844
15179
|
'use strict';
|
|
14845
15180
|
|
|
14846
15181
|
exports.__esModule = true;
|
|
@@ -14971,7 +15306,7 @@ exports.default = Root;
|
|
|
14971
15306
|
module.exports = exports['default'];
|
|
14972
15307
|
|
|
14973
15308
|
|
|
14974
|
-
},{"./container":
|
|
15309
|
+
},{"./container":50,"./lazy-result":54,"./processor":62}],65:[function(require,module,exports){
|
|
14975
15310
|
'use strict';
|
|
14976
15311
|
|
|
14977
15312
|
exports.__esModule = true;
|
|
@@ -15096,7 +15431,7 @@ exports.default = Rule;
|
|
|
15096
15431
|
module.exports = exports['default'];
|
|
15097
15432
|
|
|
15098
15433
|
|
|
15099
|
-
},{"./container":
|
|
15434
|
+
},{"./container":50,"./list":55}],66:[function(require,module,exports){
|
|
15100
15435
|
'use strict';
|
|
15101
15436
|
|
|
15102
15437
|
exports.__esModule = true;
|
|
@@ -15442,7 +15777,7 @@ exports.default = Stringifier;
|
|
|
15442
15777
|
module.exports = exports['default'];
|
|
15443
15778
|
|
|
15444
15779
|
|
|
15445
|
-
},{}],
|
|
15780
|
+
},{}],67:[function(require,module,exports){
|
|
15446
15781
|
'use strict';
|
|
15447
15782
|
|
|
15448
15783
|
exports.__esModule = true;
|
|
@@ -15461,7 +15796,7 @@ function stringify(node, builder) {
|
|
|
15461
15796
|
module.exports = exports['default'];
|
|
15462
15797
|
|
|
15463
15798
|
|
|
15464
|
-
},{"./stringifier":
|
|
15799
|
+
},{"./stringifier":66}],68:[function(require,module,exports){
|
|
15465
15800
|
'use strict';
|
|
15466
15801
|
|
|
15467
15802
|
exports.__esModule = true;
|
|
@@ -15546,7 +15881,7 @@ exports.default = terminalHighlight;
|
|
|
15546
15881
|
module.exports = exports['default'];
|
|
15547
15882
|
|
|
15548
15883
|
|
|
15549
|
-
},{"./input":
|
|
15884
|
+
},{"./input":53,"./tokenize":69,"chalk":4}],69:[function(require,module,exports){
|
|
15550
15885
|
'use strict';
|
|
15551
15886
|
|
|
15552
15887
|
exports.__esModule = true;
|
|
@@ -15854,7 +16189,7 @@ function tokenizer(input) {
|
|
|
15854
16189
|
module.exports = exports['default'];
|
|
15855
16190
|
|
|
15856
16191
|
|
|
15857
|
-
},{}],
|
|
16192
|
+
},{}],70:[function(require,module,exports){
|
|
15858
16193
|
'use strict';
|
|
15859
16194
|
|
|
15860
16195
|
exports.__esModule = true;
|
|
@@ -15908,7 +16243,7 @@ exports.default = vendor;
|
|
|
15908
16243
|
module.exports = exports['default'];
|
|
15909
16244
|
|
|
15910
16245
|
|
|
15911
|
-
},{}],
|
|
16246
|
+
},{}],71:[function(require,module,exports){
|
|
15912
16247
|
'use strict';
|
|
15913
16248
|
|
|
15914
16249
|
exports.__esModule = true;
|
|
@@ -15924,7 +16259,7 @@ function warnOnce(message) {
|
|
|
15924
16259
|
module.exports = exports['default'];
|
|
15925
16260
|
|
|
15926
16261
|
|
|
15927
|
-
},{}],
|
|
16262
|
+
},{}],72:[function(require,module,exports){
|
|
15928
16263
|
'use strict';
|
|
15929
16264
|
|
|
15930
16265
|
exports.__esModule = true;
|
|
@@ -16048,7 +16383,7 @@ exports.default = Warning;
|
|
|
16048
16383
|
module.exports = exports['default'];
|
|
16049
16384
|
|
|
16050
16385
|
|
|
16051
|
-
},{}],
|
|
16386
|
+
},{}],73:[function(require,module,exports){
|
|
16052
16387
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
16053
16388
|
/*
|
|
16054
16389
|
* Copyright 2011 Mozilla Foundation and contributors
|
|
@@ -16171,7 +16506,7 @@ ArraySet.prototype.toArray = function ArraySet_toArray() {
|
|
|
16171
16506
|
|
|
16172
16507
|
exports.ArraySet = ArraySet;
|
|
16173
16508
|
|
|
16174
|
-
},{"./util":
|
|
16509
|
+
},{"./util":82}],74:[function(require,module,exports){
|
|
16175
16510
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
16176
16511
|
/*
|
|
16177
16512
|
* Copyright 2011 Mozilla Foundation and contributors
|
|
@@ -16313,7 +16648,7 @@ exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
|
|
|
16313
16648
|
aOutParam.rest = aIndex;
|
|
16314
16649
|
};
|
|
16315
16650
|
|
|
16316
|
-
},{"./base64":
|
|
16651
|
+
},{"./base64":75}],75:[function(require,module,exports){
|
|
16317
16652
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
16318
16653
|
/*
|
|
16319
16654
|
* Copyright 2011 Mozilla Foundation and contributors
|
|
@@ -16382,7 +16717,7 @@ exports.decode = function (charCode) {
|
|
|
16382
16717
|
return -1;
|
|
16383
16718
|
};
|
|
16384
16719
|
|
|
16385
|
-
},{}],
|
|
16720
|
+
},{}],76:[function(require,module,exports){
|
|
16386
16721
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
16387
16722
|
/*
|
|
16388
16723
|
* Copyright 2011 Mozilla Foundation and contributors
|
|
@@ -16495,7 +16830,7 @@ exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
|
|
|
16495
16830
|
return index;
|
|
16496
16831
|
};
|
|
16497
16832
|
|
|
16498
|
-
},{}],
|
|
16833
|
+
},{}],77:[function(require,module,exports){
|
|
16499
16834
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
16500
16835
|
/*
|
|
16501
16836
|
* Copyright 2014 Mozilla Foundation and contributors
|
|
@@ -16576,7 +16911,7 @@ MappingList.prototype.toArray = function MappingList_toArray() {
|
|
|
16576
16911
|
|
|
16577
16912
|
exports.MappingList = MappingList;
|
|
16578
16913
|
|
|
16579
|
-
},{"./util":
|
|
16914
|
+
},{"./util":82}],78:[function(require,module,exports){
|
|
16580
16915
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
16581
16916
|
/*
|
|
16582
16917
|
* Copyright 2011 Mozilla Foundation and contributors
|
|
@@ -16692,7 +17027,7 @@ exports.quickSort = function (ary, comparator) {
|
|
|
16692
17027
|
doQuickSort(ary, comparator, 0, ary.length - 1);
|
|
16693
17028
|
};
|
|
16694
17029
|
|
|
16695
|
-
},{}],
|
|
17030
|
+
},{}],79:[function(require,module,exports){
|
|
16696
17031
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
16697
17032
|
/*
|
|
16698
17033
|
* Copyright 2011 Mozilla Foundation and contributors
|
|
@@ -17839,7 +18174,7 @@ IndexedSourceMapConsumer.prototype._parseMappings =
|
|
|
17839
18174
|
|
|
17840
18175
|
exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
|
|
17841
18176
|
|
|
17842
|
-
},{"./array-set":
|
|
18177
|
+
},{"./array-set":73,"./base64-vlq":74,"./binary-search":76,"./quick-sort":78,"./util":82}],80:[function(require,module,exports){
|
|
17843
18178
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
17844
18179
|
/*
|
|
17845
18180
|
* Copyright 2011 Mozilla Foundation and contributors
|
|
@@ -18266,7 +18601,7 @@ SourceMapGenerator.prototype.toString =
|
|
|
18266
18601
|
|
|
18267
18602
|
exports.SourceMapGenerator = SourceMapGenerator;
|
|
18268
18603
|
|
|
18269
|
-
},{"./array-set":
|
|
18604
|
+
},{"./array-set":73,"./base64-vlq":74,"./mapping-list":77,"./util":82}],81:[function(require,module,exports){
|
|
18270
18605
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
18271
18606
|
/*
|
|
18272
18607
|
* Copyright 2011 Mozilla Foundation and contributors
|
|
@@ -18681,7 +19016,7 @@ SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSou
|
|
|
18681
19016
|
|
|
18682
19017
|
exports.SourceNode = SourceNode;
|
|
18683
19018
|
|
|
18684
|
-
},{"./source-map-generator":
|
|
19019
|
+
},{"./source-map-generator":80,"./util":82}],82:[function(require,module,exports){
|
|
18685
19020
|
/* -*- Mode: js; js-indent-level: 2; -*- */
|
|
18686
19021
|
/*
|
|
18687
19022
|
* Copyright 2011 Mozilla Foundation and contributors
|
|
@@ -19171,7 +19506,7 @@ function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) {
|
|
|
19171
19506
|
}
|
|
19172
19507
|
exports.computeSourceURL = computeSourceURL;
|
|
19173
19508
|
|
|
19174
|
-
},{}],
|
|
19509
|
+
},{}],83:[function(require,module,exports){
|
|
19175
19510
|
/*
|
|
19176
19511
|
* Copyright 2009-2011 Mozilla Foundation and contributors
|
|
19177
19512
|
* Licensed under the New BSD license. See LICENSE.txt or:
|
|
@@ -19181,7 +19516,7 @@ exports.SourceMapGenerator = require('./lib/source-map-generator').SourceMapGene
|
|
|
19181
19516
|
exports.SourceMapConsumer = require('./lib/source-map-consumer').SourceMapConsumer;
|
|
19182
19517
|
exports.SourceNode = require('./lib/source-node').SourceNode;
|
|
19183
19518
|
|
|
19184
|
-
},{"./lib/source-map-consumer":
|
|
19519
|
+
},{"./lib/source-map-consumer":79,"./lib/source-map-generator":80,"./lib/source-node":81}],84:[function(require,module,exports){
|
|
19185
19520
|
(function (process){
|
|
19186
19521
|
'use strict';
|
|
19187
19522
|
|
|
@@ -19228,7 +19563,7 @@ function nextTick(fn, arg1, arg2, arg3) {
|
|
|
19228
19563
|
}
|
|
19229
19564
|
|
|
19230
19565
|
}).call(this,require('_process'))
|
|
19231
|
-
},{"_process":
|
|
19566
|
+
},{"_process":85}],85:[function(require,module,exports){
|
|
19232
19567
|
// shim for using process in browser
|
|
19233
19568
|
var process = module.exports = {};
|
|
19234
19569
|
|
|
@@ -19414,10 +19749,726 @@ process.chdir = function (dir) {
|
|
|
19414
19749
|
};
|
|
19415
19750
|
process.umask = function() { return 0; };
|
|
19416
19751
|
|
|
19417
|
-
},{}],
|
|
19418
|
-
|
|
19419
|
-
|
|
19420
|
-
|
|
19752
|
+
},{}],86:[function(require,module,exports){
|
|
19753
|
+
(function (global){
|
|
19754
|
+
/*! https://mths.be/punycode v1.4.1 by @mathias */
|
|
19755
|
+
;(function(root) {
|
|
19756
|
+
|
|
19757
|
+
/** Detect free variables */
|
|
19758
|
+
var freeExports = typeof exports == 'object' && exports &&
|
|
19759
|
+
!exports.nodeType && exports;
|
|
19760
|
+
var freeModule = typeof module == 'object' && module &&
|
|
19761
|
+
!module.nodeType && module;
|
|
19762
|
+
var freeGlobal = typeof global == 'object' && global;
|
|
19763
|
+
if (
|
|
19764
|
+
freeGlobal.global === freeGlobal ||
|
|
19765
|
+
freeGlobal.window === freeGlobal ||
|
|
19766
|
+
freeGlobal.self === freeGlobal
|
|
19767
|
+
) {
|
|
19768
|
+
root = freeGlobal;
|
|
19769
|
+
}
|
|
19770
|
+
|
|
19771
|
+
/**
|
|
19772
|
+
* The `punycode` object.
|
|
19773
|
+
* @name punycode
|
|
19774
|
+
* @type Object
|
|
19775
|
+
*/
|
|
19776
|
+
var punycode,
|
|
19777
|
+
|
|
19778
|
+
/** Highest positive signed 32-bit float value */
|
|
19779
|
+
maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
|
|
19780
|
+
|
|
19781
|
+
/** Bootstring parameters */
|
|
19782
|
+
base = 36,
|
|
19783
|
+
tMin = 1,
|
|
19784
|
+
tMax = 26,
|
|
19785
|
+
skew = 38,
|
|
19786
|
+
damp = 700,
|
|
19787
|
+
initialBias = 72,
|
|
19788
|
+
initialN = 128, // 0x80
|
|
19789
|
+
delimiter = '-', // '\x2D'
|
|
19790
|
+
|
|
19791
|
+
/** Regular expressions */
|
|
19792
|
+
regexPunycode = /^xn--/,
|
|
19793
|
+
regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
|
|
19794
|
+
regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
|
|
19795
|
+
|
|
19796
|
+
/** Error messages */
|
|
19797
|
+
errors = {
|
|
19798
|
+
'overflow': 'Overflow: input needs wider integers to process',
|
|
19799
|
+
'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
|
|
19800
|
+
'invalid-input': 'Invalid input'
|
|
19801
|
+
},
|
|
19802
|
+
|
|
19803
|
+
/** Convenience shortcuts */
|
|
19804
|
+
baseMinusTMin = base - tMin,
|
|
19805
|
+
floor = Math.floor,
|
|
19806
|
+
stringFromCharCode = String.fromCharCode,
|
|
19807
|
+
|
|
19808
|
+
/** Temporary variable */
|
|
19809
|
+
key;
|
|
19810
|
+
|
|
19811
|
+
/*--------------------------------------------------------------------------*/
|
|
19812
|
+
|
|
19813
|
+
/**
|
|
19814
|
+
* A generic error utility function.
|
|
19815
|
+
* @private
|
|
19816
|
+
* @param {String} type The error type.
|
|
19817
|
+
* @returns {Error} Throws a `RangeError` with the applicable error message.
|
|
19818
|
+
*/
|
|
19819
|
+
function error(type) {
|
|
19820
|
+
throw new RangeError(errors[type]);
|
|
19821
|
+
}
|
|
19822
|
+
|
|
19823
|
+
/**
|
|
19824
|
+
* A generic `Array#map` utility function.
|
|
19825
|
+
* @private
|
|
19826
|
+
* @param {Array} array The array to iterate over.
|
|
19827
|
+
* @param {Function} callback The function that gets called for every array
|
|
19828
|
+
* item.
|
|
19829
|
+
* @returns {Array} A new array of values returned by the callback function.
|
|
19830
|
+
*/
|
|
19831
|
+
function map(array, fn) {
|
|
19832
|
+
var length = array.length;
|
|
19833
|
+
var result = [];
|
|
19834
|
+
while (length--) {
|
|
19835
|
+
result[length] = fn(array[length]);
|
|
19836
|
+
}
|
|
19837
|
+
return result;
|
|
19838
|
+
}
|
|
19839
|
+
|
|
19840
|
+
/**
|
|
19841
|
+
* A simple `Array#map`-like wrapper to work with domain name strings or email
|
|
19842
|
+
* addresses.
|
|
19843
|
+
* @private
|
|
19844
|
+
* @param {String} domain The domain name or email address.
|
|
19845
|
+
* @param {Function} callback The function that gets called for every
|
|
19846
|
+
* character.
|
|
19847
|
+
* @returns {Array} A new string of characters returned by the callback
|
|
19848
|
+
* function.
|
|
19849
|
+
*/
|
|
19850
|
+
function mapDomain(string, fn) {
|
|
19851
|
+
var parts = string.split('@');
|
|
19852
|
+
var result = '';
|
|
19853
|
+
if (parts.length > 1) {
|
|
19854
|
+
// In email addresses, only the domain name should be punycoded. Leave
|
|
19855
|
+
// the local part (i.e. everything up to `@`) intact.
|
|
19856
|
+
result = parts[0] + '@';
|
|
19857
|
+
string = parts[1];
|
|
19858
|
+
}
|
|
19859
|
+
// Avoid `split(regex)` for IE8 compatibility. See #17.
|
|
19860
|
+
string = string.replace(regexSeparators, '\x2E');
|
|
19861
|
+
var labels = string.split('.');
|
|
19862
|
+
var encoded = map(labels, fn).join('.');
|
|
19863
|
+
return result + encoded;
|
|
19864
|
+
}
|
|
19865
|
+
|
|
19866
|
+
/**
|
|
19867
|
+
* Creates an array containing the numeric code points of each Unicode
|
|
19868
|
+
* character in the string. While JavaScript uses UCS-2 internally,
|
|
19869
|
+
* this function will convert a pair of surrogate halves (each of which
|
|
19870
|
+
* UCS-2 exposes as separate characters) into a single code point,
|
|
19871
|
+
* matching UTF-16.
|
|
19872
|
+
* @see `punycode.ucs2.encode`
|
|
19873
|
+
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
|
19874
|
+
* @memberOf punycode.ucs2
|
|
19875
|
+
* @name decode
|
|
19876
|
+
* @param {String} string The Unicode input string (UCS-2).
|
|
19877
|
+
* @returns {Array} The new array of code points.
|
|
19878
|
+
*/
|
|
19879
|
+
function ucs2decode(string) {
|
|
19880
|
+
var output = [],
|
|
19881
|
+
counter = 0,
|
|
19882
|
+
length = string.length,
|
|
19883
|
+
value,
|
|
19884
|
+
extra;
|
|
19885
|
+
while (counter < length) {
|
|
19886
|
+
value = string.charCodeAt(counter++);
|
|
19887
|
+
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
|
|
19888
|
+
// high surrogate, and there is a next character
|
|
19889
|
+
extra = string.charCodeAt(counter++);
|
|
19890
|
+
if ((extra & 0xFC00) == 0xDC00) { // low surrogate
|
|
19891
|
+
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
|
19892
|
+
} else {
|
|
19893
|
+
// unmatched surrogate; only append this code unit, in case the next
|
|
19894
|
+
// code unit is the high surrogate of a surrogate pair
|
|
19895
|
+
output.push(value);
|
|
19896
|
+
counter--;
|
|
19897
|
+
}
|
|
19898
|
+
} else {
|
|
19899
|
+
output.push(value);
|
|
19900
|
+
}
|
|
19901
|
+
}
|
|
19902
|
+
return output;
|
|
19903
|
+
}
|
|
19904
|
+
|
|
19905
|
+
/**
|
|
19906
|
+
* Creates a string based on an array of numeric code points.
|
|
19907
|
+
* @see `punycode.ucs2.decode`
|
|
19908
|
+
* @memberOf punycode.ucs2
|
|
19909
|
+
* @name encode
|
|
19910
|
+
* @param {Array} codePoints The array of numeric code points.
|
|
19911
|
+
* @returns {String} The new Unicode string (UCS-2).
|
|
19912
|
+
*/
|
|
19913
|
+
function ucs2encode(array) {
|
|
19914
|
+
return map(array, function(value) {
|
|
19915
|
+
var output = '';
|
|
19916
|
+
if (value > 0xFFFF) {
|
|
19917
|
+
value -= 0x10000;
|
|
19918
|
+
output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
|
|
19919
|
+
value = 0xDC00 | value & 0x3FF;
|
|
19920
|
+
}
|
|
19921
|
+
output += stringFromCharCode(value);
|
|
19922
|
+
return output;
|
|
19923
|
+
}).join('');
|
|
19924
|
+
}
|
|
19925
|
+
|
|
19926
|
+
/**
|
|
19927
|
+
* Converts a basic code point into a digit/integer.
|
|
19928
|
+
* @see `digitToBasic()`
|
|
19929
|
+
* @private
|
|
19930
|
+
* @param {Number} codePoint The basic numeric code point value.
|
|
19931
|
+
* @returns {Number} The numeric value of a basic code point (for use in
|
|
19932
|
+
* representing integers) in the range `0` to `base - 1`, or `base` if
|
|
19933
|
+
* the code point does not represent a value.
|
|
19934
|
+
*/
|
|
19935
|
+
function basicToDigit(codePoint) {
|
|
19936
|
+
if (codePoint - 48 < 10) {
|
|
19937
|
+
return codePoint - 22;
|
|
19938
|
+
}
|
|
19939
|
+
if (codePoint - 65 < 26) {
|
|
19940
|
+
return codePoint - 65;
|
|
19941
|
+
}
|
|
19942
|
+
if (codePoint - 97 < 26) {
|
|
19943
|
+
return codePoint - 97;
|
|
19944
|
+
}
|
|
19945
|
+
return base;
|
|
19946
|
+
}
|
|
19947
|
+
|
|
19948
|
+
/**
|
|
19949
|
+
* Converts a digit/integer into a basic code point.
|
|
19950
|
+
* @see `basicToDigit()`
|
|
19951
|
+
* @private
|
|
19952
|
+
* @param {Number} digit The numeric value of a basic code point.
|
|
19953
|
+
* @returns {Number} The basic code point whose value (when used for
|
|
19954
|
+
* representing integers) is `digit`, which needs to be in the range
|
|
19955
|
+
* `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
|
|
19956
|
+
* used; else, the lowercase form is used. The behavior is undefined
|
|
19957
|
+
* if `flag` is non-zero and `digit` has no uppercase form.
|
|
19958
|
+
*/
|
|
19959
|
+
function digitToBasic(digit, flag) {
|
|
19960
|
+
// 0..25 map to ASCII a..z or A..Z
|
|
19961
|
+
// 26..35 map to ASCII 0..9
|
|
19962
|
+
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
|
19963
|
+
}
|
|
19964
|
+
|
|
19965
|
+
/**
|
|
19966
|
+
* Bias adaptation function as per section 3.4 of RFC 3492.
|
|
19967
|
+
* https://tools.ietf.org/html/rfc3492#section-3.4
|
|
19968
|
+
* @private
|
|
19969
|
+
*/
|
|
19970
|
+
function adapt(delta, numPoints, firstTime) {
|
|
19971
|
+
var k = 0;
|
|
19972
|
+
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
|
19973
|
+
delta += floor(delta / numPoints);
|
|
19974
|
+
for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
|
|
19975
|
+
delta = floor(delta / baseMinusTMin);
|
|
19976
|
+
}
|
|
19977
|
+
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
|
19978
|
+
}
|
|
19979
|
+
|
|
19980
|
+
/**
|
|
19981
|
+
* Converts a Punycode string of ASCII-only symbols to a string of Unicode
|
|
19982
|
+
* symbols.
|
|
19983
|
+
* @memberOf punycode
|
|
19984
|
+
* @param {String} input The Punycode string of ASCII-only symbols.
|
|
19985
|
+
* @returns {String} The resulting string of Unicode symbols.
|
|
19986
|
+
*/
|
|
19987
|
+
function decode(input) {
|
|
19988
|
+
// Don't use UCS-2
|
|
19989
|
+
var output = [],
|
|
19990
|
+
inputLength = input.length,
|
|
19991
|
+
out,
|
|
19992
|
+
i = 0,
|
|
19993
|
+
n = initialN,
|
|
19994
|
+
bias = initialBias,
|
|
19995
|
+
basic,
|
|
19996
|
+
j,
|
|
19997
|
+
index,
|
|
19998
|
+
oldi,
|
|
19999
|
+
w,
|
|
20000
|
+
k,
|
|
20001
|
+
digit,
|
|
20002
|
+
t,
|
|
20003
|
+
/** Cached calculation results */
|
|
20004
|
+
baseMinusT;
|
|
20005
|
+
|
|
20006
|
+
// Handle the basic code points: let `basic` be the number of input code
|
|
20007
|
+
// points before the last delimiter, or `0` if there is none, then copy
|
|
20008
|
+
// the first basic code points to the output.
|
|
20009
|
+
|
|
20010
|
+
basic = input.lastIndexOf(delimiter);
|
|
20011
|
+
if (basic < 0) {
|
|
20012
|
+
basic = 0;
|
|
20013
|
+
}
|
|
20014
|
+
|
|
20015
|
+
for (j = 0; j < basic; ++j) {
|
|
20016
|
+
// if it's not a basic code point
|
|
20017
|
+
if (input.charCodeAt(j) >= 0x80) {
|
|
20018
|
+
error('not-basic');
|
|
20019
|
+
}
|
|
20020
|
+
output.push(input.charCodeAt(j));
|
|
20021
|
+
}
|
|
20022
|
+
|
|
20023
|
+
// Main decoding loop: start just after the last delimiter if any basic code
|
|
20024
|
+
// points were copied; start at the beginning otherwise.
|
|
20025
|
+
|
|
20026
|
+
for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
|
|
20027
|
+
|
|
20028
|
+
// `index` is the index of the next character to be consumed.
|
|
20029
|
+
// Decode a generalized variable-length integer into `delta`,
|
|
20030
|
+
// which gets added to `i`. The overflow checking is easier
|
|
20031
|
+
// if we increase `i` as we go, then subtract off its starting
|
|
20032
|
+
// value at the end to obtain `delta`.
|
|
20033
|
+
for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
|
|
20034
|
+
|
|
20035
|
+
if (index >= inputLength) {
|
|
20036
|
+
error('invalid-input');
|
|
20037
|
+
}
|
|
20038
|
+
|
|
20039
|
+
digit = basicToDigit(input.charCodeAt(index++));
|
|
20040
|
+
|
|
20041
|
+
if (digit >= base || digit > floor((maxInt - i) / w)) {
|
|
20042
|
+
error('overflow');
|
|
20043
|
+
}
|
|
20044
|
+
|
|
20045
|
+
i += digit * w;
|
|
20046
|
+
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
|
20047
|
+
|
|
20048
|
+
if (digit < t) {
|
|
20049
|
+
break;
|
|
20050
|
+
}
|
|
20051
|
+
|
|
20052
|
+
baseMinusT = base - t;
|
|
20053
|
+
if (w > floor(maxInt / baseMinusT)) {
|
|
20054
|
+
error('overflow');
|
|
20055
|
+
}
|
|
20056
|
+
|
|
20057
|
+
w *= baseMinusT;
|
|
20058
|
+
|
|
20059
|
+
}
|
|
20060
|
+
|
|
20061
|
+
out = output.length + 1;
|
|
20062
|
+
bias = adapt(i - oldi, out, oldi == 0);
|
|
20063
|
+
|
|
20064
|
+
// `i` was supposed to wrap around from `out` to `0`,
|
|
20065
|
+
// incrementing `n` each time, so we'll fix that now:
|
|
20066
|
+
if (floor(i / out) > maxInt - n) {
|
|
20067
|
+
error('overflow');
|
|
20068
|
+
}
|
|
20069
|
+
|
|
20070
|
+
n += floor(i / out);
|
|
20071
|
+
i %= out;
|
|
20072
|
+
|
|
20073
|
+
// Insert `n` at position `i` of the output
|
|
20074
|
+
output.splice(i++, 0, n);
|
|
20075
|
+
|
|
20076
|
+
}
|
|
20077
|
+
|
|
20078
|
+
return ucs2encode(output);
|
|
20079
|
+
}
|
|
20080
|
+
|
|
20081
|
+
/**
|
|
20082
|
+
* Converts a string of Unicode symbols (e.g. a domain name label) to a
|
|
20083
|
+
* Punycode string of ASCII-only symbols.
|
|
20084
|
+
* @memberOf punycode
|
|
20085
|
+
* @param {String} input The string of Unicode symbols.
|
|
20086
|
+
* @returns {String} The resulting Punycode string of ASCII-only symbols.
|
|
20087
|
+
*/
|
|
20088
|
+
function encode(input) {
|
|
20089
|
+
var n,
|
|
20090
|
+
delta,
|
|
20091
|
+
handledCPCount,
|
|
20092
|
+
basicLength,
|
|
20093
|
+
bias,
|
|
20094
|
+
j,
|
|
20095
|
+
m,
|
|
20096
|
+
q,
|
|
20097
|
+
k,
|
|
20098
|
+
t,
|
|
20099
|
+
currentValue,
|
|
20100
|
+
output = [],
|
|
20101
|
+
/** `inputLength` will hold the number of code points in `input`. */
|
|
20102
|
+
inputLength,
|
|
20103
|
+
/** Cached calculation results */
|
|
20104
|
+
handledCPCountPlusOne,
|
|
20105
|
+
baseMinusT,
|
|
20106
|
+
qMinusT;
|
|
20107
|
+
|
|
20108
|
+
// Convert the input in UCS-2 to Unicode
|
|
20109
|
+
input = ucs2decode(input);
|
|
20110
|
+
|
|
20111
|
+
// Cache the length
|
|
20112
|
+
inputLength = input.length;
|
|
20113
|
+
|
|
20114
|
+
// Initialize the state
|
|
20115
|
+
n = initialN;
|
|
20116
|
+
delta = 0;
|
|
20117
|
+
bias = initialBias;
|
|
20118
|
+
|
|
20119
|
+
// Handle the basic code points
|
|
20120
|
+
for (j = 0; j < inputLength; ++j) {
|
|
20121
|
+
currentValue = input[j];
|
|
20122
|
+
if (currentValue < 0x80) {
|
|
20123
|
+
output.push(stringFromCharCode(currentValue));
|
|
20124
|
+
}
|
|
20125
|
+
}
|
|
20126
|
+
|
|
20127
|
+
handledCPCount = basicLength = output.length;
|
|
20128
|
+
|
|
20129
|
+
// `handledCPCount` is the number of code points that have been handled;
|
|
20130
|
+
// `basicLength` is the number of basic code points.
|
|
20131
|
+
|
|
20132
|
+
// Finish the basic string - if it is not empty - with a delimiter
|
|
20133
|
+
if (basicLength) {
|
|
20134
|
+
output.push(delimiter);
|
|
20135
|
+
}
|
|
20136
|
+
|
|
20137
|
+
// Main encoding loop:
|
|
20138
|
+
while (handledCPCount < inputLength) {
|
|
20139
|
+
|
|
20140
|
+
// All non-basic code points < n have been handled already. Find the next
|
|
20141
|
+
// larger one:
|
|
20142
|
+
for (m = maxInt, j = 0; j < inputLength; ++j) {
|
|
20143
|
+
currentValue = input[j];
|
|
20144
|
+
if (currentValue >= n && currentValue < m) {
|
|
20145
|
+
m = currentValue;
|
|
20146
|
+
}
|
|
20147
|
+
}
|
|
20148
|
+
|
|
20149
|
+
// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
|
|
20150
|
+
// but guard against overflow
|
|
20151
|
+
handledCPCountPlusOne = handledCPCount + 1;
|
|
20152
|
+
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
|
|
20153
|
+
error('overflow');
|
|
20154
|
+
}
|
|
20155
|
+
|
|
20156
|
+
delta += (m - n) * handledCPCountPlusOne;
|
|
20157
|
+
n = m;
|
|
20158
|
+
|
|
20159
|
+
for (j = 0; j < inputLength; ++j) {
|
|
20160
|
+
currentValue = input[j];
|
|
20161
|
+
|
|
20162
|
+
if (currentValue < n && ++delta > maxInt) {
|
|
20163
|
+
error('overflow');
|
|
20164
|
+
}
|
|
20165
|
+
|
|
20166
|
+
if (currentValue == n) {
|
|
20167
|
+
// Represent delta as a generalized variable-length integer
|
|
20168
|
+
for (q = delta, k = base; /* no condition */; k += base) {
|
|
20169
|
+
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
|
20170
|
+
if (q < t) {
|
|
20171
|
+
break;
|
|
20172
|
+
}
|
|
20173
|
+
qMinusT = q - t;
|
|
20174
|
+
baseMinusT = base - t;
|
|
20175
|
+
output.push(
|
|
20176
|
+
stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
|
|
20177
|
+
);
|
|
20178
|
+
q = floor(qMinusT / baseMinusT);
|
|
20179
|
+
}
|
|
20180
|
+
|
|
20181
|
+
output.push(stringFromCharCode(digitToBasic(q, 0)));
|
|
20182
|
+
bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
|
|
20183
|
+
delta = 0;
|
|
20184
|
+
++handledCPCount;
|
|
20185
|
+
}
|
|
20186
|
+
}
|
|
20187
|
+
|
|
20188
|
+
++delta;
|
|
20189
|
+
++n;
|
|
20190
|
+
|
|
20191
|
+
}
|
|
20192
|
+
return output.join('');
|
|
20193
|
+
}
|
|
20194
|
+
|
|
20195
|
+
/**
|
|
20196
|
+
* Converts a Punycode string representing a domain name or an email address
|
|
20197
|
+
* to Unicode. Only the Punycoded parts of the input will be converted, i.e.
|
|
20198
|
+
* it doesn't matter if you call it on a string that has already been
|
|
20199
|
+
* converted to Unicode.
|
|
20200
|
+
* @memberOf punycode
|
|
20201
|
+
* @param {String} input The Punycoded domain name or email address to
|
|
20202
|
+
* convert to Unicode.
|
|
20203
|
+
* @returns {String} The Unicode representation of the given Punycode
|
|
20204
|
+
* string.
|
|
20205
|
+
*/
|
|
20206
|
+
function toUnicode(input) {
|
|
20207
|
+
return mapDomain(input, function(string) {
|
|
20208
|
+
return regexPunycode.test(string)
|
|
20209
|
+
? decode(string.slice(4).toLowerCase())
|
|
20210
|
+
: string;
|
|
20211
|
+
});
|
|
20212
|
+
}
|
|
20213
|
+
|
|
20214
|
+
/**
|
|
20215
|
+
* Converts a Unicode string representing a domain name or an email address to
|
|
20216
|
+
* Punycode. Only the non-ASCII parts of the domain name will be converted,
|
|
20217
|
+
* i.e. it doesn't matter if you call it with a domain that's already in
|
|
20218
|
+
* ASCII.
|
|
20219
|
+
* @memberOf punycode
|
|
20220
|
+
* @param {String} input The domain name or email address to convert, as a
|
|
20221
|
+
* Unicode string.
|
|
20222
|
+
* @returns {String} The Punycode representation of the given domain name or
|
|
20223
|
+
* email address.
|
|
20224
|
+
*/
|
|
20225
|
+
function toASCII(input) {
|
|
20226
|
+
return mapDomain(input, function(string) {
|
|
20227
|
+
return regexNonASCII.test(string)
|
|
20228
|
+
? 'xn--' + encode(string)
|
|
20229
|
+
: string;
|
|
20230
|
+
});
|
|
20231
|
+
}
|
|
20232
|
+
|
|
20233
|
+
/*--------------------------------------------------------------------------*/
|
|
20234
|
+
|
|
20235
|
+
/** Define the public API */
|
|
20236
|
+
punycode = {
|
|
20237
|
+
/**
|
|
20238
|
+
* A string representing the current Punycode.js version number.
|
|
20239
|
+
* @memberOf punycode
|
|
20240
|
+
* @type String
|
|
20241
|
+
*/
|
|
20242
|
+
'version': '1.4.1',
|
|
20243
|
+
/**
|
|
20244
|
+
* An object of methods to convert from JavaScript's internal character
|
|
20245
|
+
* representation (UCS-2) to Unicode code points, and back.
|
|
20246
|
+
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
|
20247
|
+
* @memberOf punycode
|
|
20248
|
+
* @type Object
|
|
20249
|
+
*/
|
|
20250
|
+
'ucs2': {
|
|
20251
|
+
'decode': ucs2decode,
|
|
20252
|
+
'encode': ucs2encode
|
|
20253
|
+
},
|
|
20254
|
+
'decode': decode,
|
|
20255
|
+
'encode': encode,
|
|
20256
|
+
'toASCII': toASCII,
|
|
20257
|
+
'toUnicode': toUnicode
|
|
20258
|
+
};
|
|
20259
|
+
|
|
20260
|
+
/** Expose `punycode` */
|
|
20261
|
+
// Some AMD build optimizers, like r.js, check for specific condition patterns
|
|
20262
|
+
// like the following:
|
|
20263
|
+
if (
|
|
20264
|
+
typeof define == 'function' &&
|
|
20265
|
+
typeof define.amd == 'object' &&
|
|
20266
|
+
define.amd
|
|
20267
|
+
) {
|
|
20268
|
+
define('punycode', function() {
|
|
20269
|
+
return punycode;
|
|
20270
|
+
});
|
|
20271
|
+
} else if (freeExports && freeModule) {
|
|
20272
|
+
if (module.exports == freeExports) {
|
|
20273
|
+
// in Node.js, io.js, or RingoJS v0.8.0+
|
|
20274
|
+
freeModule.exports = punycode;
|
|
20275
|
+
} else {
|
|
20276
|
+
// in Narwhal or RingoJS v0.7.0-
|
|
20277
|
+
for (key in punycode) {
|
|
20278
|
+
punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
|
|
20279
|
+
}
|
|
20280
|
+
}
|
|
20281
|
+
} else {
|
|
20282
|
+
// in Rhino or a web browser
|
|
20283
|
+
root.punycode = punycode;
|
|
20284
|
+
}
|
|
20285
|
+
|
|
20286
|
+
}(this));
|
|
20287
|
+
|
|
20288
|
+
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
20289
|
+
},{}],87:[function(require,module,exports){
|
|
20290
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
20291
|
+
//
|
|
20292
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
20293
|
+
// copy of this software and associated documentation files (the
|
|
20294
|
+
// "Software"), to deal in the Software without restriction, including
|
|
20295
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
20296
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
20297
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
20298
|
+
// following conditions:
|
|
20299
|
+
//
|
|
20300
|
+
// The above copyright notice and this permission notice shall be included
|
|
20301
|
+
// in all copies or substantial portions of the Software.
|
|
20302
|
+
//
|
|
20303
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
20304
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
20305
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
20306
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
20307
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
20308
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
20309
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20310
|
+
|
|
20311
|
+
'use strict';
|
|
20312
|
+
|
|
20313
|
+
// If obj.hasOwnProperty has been overridden, then calling
|
|
20314
|
+
// obj.hasOwnProperty(prop) will break.
|
|
20315
|
+
// See: https://github.com/joyent/node/issues/1707
|
|
20316
|
+
function hasOwnProperty(obj, prop) {
|
|
20317
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
20318
|
+
}
|
|
20319
|
+
|
|
20320
|
+
module.exports = function(qs, sep, eq, options) {
|
|
20321
|
+
sep = sep || '&';
|
|
20322
|
+
eq = eq || '=';
|
|
20323
|
+
var obj = {};
|
|
20324
|
+
|
|
20325
|
+
if (typeof qs !== 'string' || qs.length === 0) {
|
|
20326
|
+
return obj;
|
|
20327
|
+
}
|
|
20328
|
+
|
|
20329
|
+
var regexp = /\+/g;
|
|
20330
|
+
qs = qs.split(sep);
|
|
20331
|
+
|
|
20332
|
+
var maxKeys = 1000;
|
|
20333
|
+
if (options && typeof options.maxKeys === 'number') {
|
|
20334
|
+
maxKeys = options.maxKeys;
|
|
20335
|
+
}
|
|
20336
|
+
|
|
20337
|
+
var len = qs.length;
|
|
20338
|
+
// maxKeys <= 0 means that we should not limit keys count
|
|
20339
|
+
if (maxKeys > 0 && len > maxKeys) {
|
|
20340
|
+
len = maxKeys;
|
|
20341
|
+
}
|
|
20342
|
+
|
|
20343
|
+
for (var i = 0; i < len; ++i) {
|
|
20344
|
+
var x = qs[i].replace(regexp, '%20'),
|
|
20345
|
+
idx = x.indexOf(eq),
|
|
20346
|
+
kstr, vstr, k, v;
|
|
20347
|
+
|
|
20348
|
+
if (idx >= 0) {
|
|
20349
|
+
kstr = x.substr(0, idx);
|
|
20350
|
+
vstr = x.substr(idx + 1);
|
|
20351
|
+
} else {
|
|
20352
|
+
kstr = x;
|
|
20353
|
+
vstr = '';
|
|
20354
|
+
}
|
|
20355
|
+
|
|
20356
|
+
k = decodeURIComponent(kstr);
|
|
20357
|
+
v = decodeURIComponent(vstr);
|
|
20358
|
+
|
|
20359
|
+
if (!hasOwnProperty(obj, k)) {
|
|
20360
|
+
obj[k] = v;
|
|
20361
|
+
} else if (isArray(obj[k])) {
|
|
20362
|
+
obj[k].push(v);
|
|
20363
|
+
} else {
|
|
20364
|
+
obj[k] = [obj[k], v];
|
|
20365
|
+
}
|
|
20366
|
+
}
|
|
20367
|
+
|
|
20368
|
+
return obj;
|
|
20369
|
+
};
|
|
20370
|
+
|
|
20371
|
+
var isArray = Array.isArray || function (xs) {
|
|
20372
|
+
return Object.prototype.toString.call(xs) === '[object Array]';
|
|
20373
|
+
};
|
|
20374
|
+
|
|
20375
|
+
},{}],88:[function(require,module,exports){
|
|
20376
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
20377
|
+
//
|
|
20378
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
20379
|
+
// copy of this software and associated documentation files (the
|
|
20380
|
+
// "Software"), to deal in the Software without restriction, including
|
|
20381
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
20382
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
20383
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
20384
|
+
// following conditions:
|
|
20385
|
+
//
|
|
20386
|
+
// The above copyright notice and this permission notice shall be included
|
|
20387
|
+
// in all copies or substantial portions of the Software.
|
|
20388
|
+
//
|
|
20389
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
20390
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
20391
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
20392
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
20393
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
20394
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
20395
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20396
|
+
|
|
20397
|
+
'use strict';
|
|
20398
|
+
|
|
20399
|
+
var stringifyPrimitive = function(v) {
|
|
20400
|
+
switch (typeof v) {
|
|
20401
|
+
case 'string':
|
|
20402
|
+
return v;
|
|
20403
|
+
|
|
20404
|
+
case 'boolean':
|
|
20405
|
+
return v ? 'true' : 'false';
|
|
20406
|
+
|
|
20407
|
+
case 'number':
|
|
20408
|
+
return isFinite(v) ? v : '';
|
|
20409
|
+
|
|
20410
|
+
default:
|
|
20411
|
+
return '';
|
|
20412
|
+
}
|
|
20413
|
+
};
|
|
20414
|
+
|
|
20415
|
+
module.exports = function(obj, sep, eq, name) {
|
|
20416
|
+
sep = sep || '&';
|
|
20417
|
+
eq = eq || '=';
|
|
20418
|
+
if (obj === null) {
|
|
20419
|
+
obj = undefined;
|
|
20420
|
+
}
|
|
20421
|
+
|
|
20422
|
+
if (typeof obj === 'object') {
|
|
20423
|
+
return map(objectKeys(obj), function(k) {
|
|
20424
|
+
var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
|
|
20425
|
+
if (isArray(obj[k])) {
|
|
20426
|
+
return map(obj[k], function(v) {
|
|
20427
|
+
return ks + encodeURIComponent(stringifyPrimitive(v));
|
|
20428
|
+
}).join(sep);
|
|
20429
|
+
} else {
|
|
20430
|
+
return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
|
|
20431
|
+
}
|
|
20432
|
+
}).join(sep);
|
|
20433
|
+
|
|
20434
|
+
}
|
|
20435
|
+
|
|
20436
|
+
if (!name) return '';
|
|
20437
|
+
return encodeURIComponent(stringifyPrimitive(name)) + eq +
|
|
20438
|
+
encodeURIComponent(stringifyPrimitive(obj));
|
|
20439
|
+
};
|
|
20440
|
+
|
|
20441
|
+
var isArray = Array.isArray || function (xs) {
|
|
20442
|
+
return Object.prototype.toString.call(xs) === '[object Array]';
|
|
20443
|
+
};
|
|
20444
|
+
|
|
20445
|
+
function map (xs, f) {
|
|
20446
|
+
if (xs.map) return xs.map(f);
|
|
20447
|
+
var res = [];
|
|
20448
|
+
for (var i = 0; i < xs.length; i++) {
|
|
20449
|
+
res.push(f(xs[i], i));
|
|
20450
|
+
}
|
|
20451
|
+
return res;
|
|
20452
|
+
}
|
|
20453
|
+
|
|
20454
|
+
var objectKeys = Object.keys || function (obj) {
|
|
20455
|
+
var res = [];
|
|
20456
|
+
for (var key in obj) {
|
|
20457
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
|
|
20458
|
+
}
|
|
20459
|
+
return res;
|
|
20460
|
+
};
|
|
20461
|
+
|
|
20462
|
+
},{}],89:[function(require,module,exports){
|
|
20463
|
+
'use strict';
|
|
20464
|
+
|
|
20465
|
+
exports.decode = exports.parse = require('./decode');
|
|
20466
|
+
exports.encode = exports.stringify = require('./encode');
|
|
20467
|
+
|
|
20468
|
+
},{"./decode":87,"./encode":88}],90:[function(require,module,exports){
|
|
20469
|
+
/* eslint-disable node/no-deprecated-api */
|
|
20470
|
+
var buffer = require('buffer')
|
|
20471
|
+
var Buffer = buffer.Buffer
|
|
19421
20472
|
|
|
19422
20473
|
// alternative to using Object.keys for old browsers
|
|
19423
20474
|
function copyProps (src, dst) {
|
|
@@ -19478,7 +20529,7 @@ SafeBuffer.allocUnsafeSlow = function (size) {
|
|
|
19478
20529
|
return buffer.SlowBuffer(size)
|
|
19479
20530
|
}
|
|
19480
20531
|
|
|
19481
|
-
},{"buffer":5}],
|
|
20532
|
+
},{"buffer":5}],91:[function(require,module,exports){
|
|
19482
20533
|
'use strict';
|
|
19483
20534
|
var numberIsNan = require('number-is-nan');
|
|
19484
20535
|
var arrayUniq = require('array-uniq');
|
|
@@ -19543,7 +20594,7 @@ exports.stringify = function (arr) {
|
|
|
19543
20594
|
})).join(', ');
|
|
19544
20595
|
}
|
|
19545
20596
|
|
|
19546
|
-
},{"array-uniq":2,"number-is-nan":
|
|
20597
|
+
},{"array-uniq":2,"number-is-nan":46}],92:[function(require,module,exports){
|
|
19547
20598
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
19548
20599
|
//
|
|
19549
20600
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
@@ -19672,10 +20723,10 @@ Stream.prototype.pipe = function(dest, options) {
|
|
|
19672
20723
|
return dest;
|
|
19673
20724
|
};
|
|
19674
20725
|
|
|
19675
|
-
},{"events":28,"inherits":38,"readable-stream/duplex.js":
|
|
20726
|
+
},{"events":28,"inherits":38,"readable-stream/duplex.js":93,"readable-stream/passthrough.js":103,"readable-stream/readable.js":104,"readable-stream/transform.js":105,"readable-stream/writable.js":106}],93:[function(require,module,exports){
|
|
19676
20727
|
module.exports = require('./lib/_stream_duplex.js');
|
|
19677
20728
|
|
|
19678
|
-
},{"./lib/_stream_duplex.js":
|
|
20729
|
+
},{"./lib/_stream_duplex.js":94}],94:[function(require,module,exports){
|
|
19679
20730
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
19680
20731
|
//
|
|
19681
20732
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
@@ -19800,7 +20851,7 @@ function forEach(xs, f) {
|
|
|
19800
20851
|
f(xs[i], i);
|
|
19801
20852
|
}
|
|
19802
20853
|
}
|
|
19803
|
-
},{"./_stream_readable":
|
|
20854
|
+
},{"./_stream_readable":96,"./_stream_writable":98,"core-util-is":6,"inherits":102,"process-nextick-args":84}],95:[function(require,module,exports){
|
|
19804
20855
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
19805
20856
|
//
|
|
19806
20857
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
@@ -19848,7 +20899,7 @@ function PassThrough(options) {
|
|
|
19848
20899
|
PassThrough.prototype._transform = function (chunk, encoding, cb) {
|
|
19849
20900
|
cb(null, chunk);
|
|
19850
20901
|
};
|
|
19851
|
-
},{"./_stream_transform":
|
|
20902
|
+
},{"./_stream_transform":97,"core-util-is":6,"inherits":102}],96:[function(require,module,exports){
|
|
19852
20903
|
(function (process,global){
|
|
19853
20904
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
19854
20905
|
//
|
|
@@ -20858,7 +21909,7 @@ function indexOf(xs, x) {
|
|
|
20858
21909
|
return -1;
|
|
20859
21910
|
}
|
|
20860
21911
|
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
20861
|
-
},{"./_stream_duplex":
|
|
21912
|
+
},{"./_stream_duplex":94,"./internal/streams/BufferList":99,"./internal/streams/destroy":100,"./internal/streams/stream":101,"_process":85,"core-util-is":6,"events":28,"inherits":102,"isarray":40,"process-nextick-args":84,"safe-buffer":90,"string_decoder/":107,"util":4}],97:[function(require,module,exports){
|
|
20862
21913
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
20863
21914
|
//
|
|
20864
21915
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
@@ -21073,7 +22124,7 @@ function done(stream, er, data) {
|
|
|
21073
22124
|
|
|
21074
22125
|
return stream.push(null);
|
|
21075
22126
|
}
|
|
21076
|
-
},{"./_stream_duplex":
|
|
22127
|
+
},{"./_stream_duplex":94,"core-util-is":6,"inherits":102}],98:[function(require,module,exports){
|
|
21077
22128
|
(function (process,global){
|
|
21078
22129
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
21079
22130
|
//
|
|
@@ -21740,7 +22791,7 @@ Writable.prototype._destroy = function (err, cb) {
|
|
|
21740
22791
|
cb(err);
|
|
21741
22792
|
};
|
|
21742
22793
|
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
21743
|
-
},{"./_stream_duplex":
|
|
22794
|
+
},{"./_stream_duplex":94,"./internal/streams/destroy":100,"./internal/streams/stream":101,"_process":85,"core-util-is":6,"inherits":102,"process-nextick-args":84,"safe-buffer":90,"util-deprecate":111}],99:[function(require,module,exports){
|
|
21744
22795
|
'use strict';
|
|
21745
22796
|
|
|
21746
22797
|
/*<replacement>*/
|
|
@@ -21815,7 +22866,7 @@ module.exports = function () {
|
|
|
21815
22866
|
|
|
21816
22867
|
return BufferList;
|
|
21817
22868
|
}();
|
|
21818
|
-
},{"safe-buffer":
|
|
22869
|
+
},{"safe-buffer":90}],100:[function(require,module,exports){
|
|
21819
22870
|
'use strict';
|
|
21820
22871
|
|
|
21821
22872
|
/*<replacement>*/
|
|
@@ -21888,15 +22939,15 @@ module.exports = {
|
|
|
21888
22939
|
destroy: destroy,
|
|
21889
22940
|
undestroy: undestroy
|
|
21890
22941
|
};
|
|
21891
|
-
},{"process-nextick-args":
|
|
22942
|
+
},{"process-nextick-args":84}],101:[function(require,module,exports){
|
|
21892
22943
|
module.exports = require('events').EventEmitter;
|
|
21893
22944
|
|
|
21894
|
-
},{"events":28}],
|
|
22945
|
+
},{"events":28}],102:[function(require,module,exports){
|
|
21895
22946
|
arguments[4][38][0].apply(exports,arguments)
|
|
21896
|
-
},{"dup":38}],
|
|
22947
|
+
},{"dup":38}],103:[function(require,module,exports){
|
|
21897
22948
|
module.exports = require('./readable').PassThrough
|
|
21898
22949
|
|
|
21899
|
-
},{"./readable":
|
|
22950
|
+
},{"./readable":104}],104:[function(require,module,exports){
|
|
21900
22951
|
exports = module.exports = require('./lib/_stream_readable.js');
|
|
21901
22952
|
exports.Stream = exports;
|
|
21902
22953
|
exports.Readable = exports;
|
|
@@ -21905,13 +22956,13 @@ exports.Duplex = require('./lib/_stream_duplex.js');
|
|
|
21905
22956
|
exports.Transform = require('./lib/_stream_transform.js');
|
|
21906
22957
|
exports.PassThrough = require('./lib/_stream_passthrough.js');
|
|
21907
22958
|
|
|
21908
|
-
},{"./lib/_stream_duplex.js":
|
|
22959
|
+
},{"./lib/_stream_duplex.js":94,"./lib/_stream_passthrough.js":95,"./lib/_stream_readable.js":96,"./lib/_stream_transform.js":97,"./lib/_stream_writable.js":98}],105:[function(require,module,exports){
|
|
21909
22960
|
module.exports = require('./readable').Transform
|
|
21910
22961
|
|
|
21911
|
-
},{"./readable":
|
|
22962
|
+
},{"./readable":104}],106:[function(require,module,exports){
|
|
21912
22963
|
module.exports = require('./lib/_stream_writable.js');
|
|
21913
22964
|
|
|
21914
|
-
},{"./lib/_stream_writable.js":
|
|
22965
|
+
},{"./lib/_stream_writable.js":98}],107:[function(require,module,exports){
|
|
21915
22966
|
'use strict';
|
|
21916
22967
|
|
|
21917
22968
|
var Buffer = require('safe-buffer').Buffer;
|
|
@@ -22184,7 +23235,7 @@ function simpleWrite(buf) {
|
|
|
22184
23235
|
function simpleEnd(buf) {
|
|
22185
23236
|
return buf && buf.length ? this.write(buf) : '';
|
|
22186
23237
|
}
|
|
22187
|
-
},{"safe-buffer":
|
|
23238
|
+
},{"safe-buffer":90}],108:[function(require,module,exports){
|
|
22188
23239
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
22189
23240
|
//
|
|
22190
23241
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
@@ -22407,7 +23458,759 @@ function base64DetectIncompleteChar(buffer) {
|
|
|
22407
23458
|
this.charLength = this.charReceived ? 3 : 0;
|
|
22408
23459
|
}
|
|
22409
23460
|
|
|
22410
|
-
},{"buffer":5}],
|
|
23461
|
+
},{"buffer":5}],109:[function(require,module,exports){
|
|
23462
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
23463
|
+
//
|
|
23464
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
23465
|
+
// copy of this software and associated documentation files (the
|
|
23466
|
+
// "Software"), to deal in the Software without restriction, including
|
|
23467
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
23468
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
23469
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
23470
|
+
// following conditions:
|
|
23471
|
+
//
|
|
23472
|
+
// The above copyright notice and this permission notice shall be included
|
|
23473
|
+
// in all copies or substantial portions of the Software.
|
|
23474
|
+
//
|
|
23475
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
23476
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
23477
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
23478
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
23479
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
23480
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
23481
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23482
|
+
|
|
23483
|
+
'use strict';
|
|
23484
|
+
|
|
23485
|
+
var punycode = require('punycode');
|
|
23486
|
+
var util = require('./util');
|
|
23487
|
+
|
|
23488
|
+
exports.parse = urlParse;
|
|
23489
|
+
exports.resolve = urlResolve;
|
|
23490
|
+
exports.resolveObject = urlResolveObject;
|
|
23491
|
+
exports.format = urlFormat;
|
|
23492
|
+
|
|
23493
|
+
exports.Url = Url;
|
|
23494
|
+
|
|
23495
|
+
function Url() {
|
|
23496
|
+
this.protocol = null;
|
|
23497
|
+
this.slashes = null;
|
|
23498
|
+
this.auth = null;
|
|
23499
|
+
this.host = null;
|
|
23500
|
+
this.port = null;
|
|
23501
|
+
this.hostname = null;
|
|
23502
|
+
this.hash = null;
|
|
23503
|
+
this.search = null;
|
|
23504
|
+
this.query = null;
|
|
23505
|
+
this.pathname = null;
|
|
23506
|
+
this.path = null;
|
|
23507
|
+
this.href = null;
|
|
23508
|
+
}
|
|
23509
|
+
|
|
23510
|
+
// Reference: RFC 3986, RFC 1808, RFC 2396
|
|
23511
|
+
|
|
23512
|
+
// define these here so at least they only have to be
|
|
23513
|
+
// compiled once on the first module load.
|
|
23514
|
+
var protocolPattern = /^([a-z0-9.+-]+:)/i,
|
|
23515
|
+
portPattern = /:[0-9]*$/,
|
|
23516
|
+
|
|
23517
|
+
// Special case for a simple path URL
|
|
23518
|
+
simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
|
|
23519
|
+
|
|
23520
|
+
// RFC 2396: characters reserved for delimiting URLs.
|
|
23521
|
+
// We actually just auto-escape these.
|
|
23522
|
+
delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
|
|
23523
|
+
|
|
23524
|
+
// RFC 2396: characters not allowed for various reasons.
|
|
23525
|
+
unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
|
|
23526
|
+
|
|
23527
|
+
// Allowed by RFCs, but cause of XSS attacks. Always escape these.
|
|
23528
|
+
autoEscape = ['\''].concat(unwise),
|
|
23529
|
+
// Characters that are never ever allowed in a hostname.
|
|
23530
|
+
// Note that any invalid chars are also handled, but these
|
|
23531
|
+
// are the ones that are *expected* to be seen, so we fast-path
|
|
23532
|
+
// them.
|
|
23533
|
+
nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
|
|
23534
|
+
hostEndingChars = ['/', '?', '#'],
|
|
23535
|
+
hostnameMaxLen = 255,
|
|
23536
|
+
hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
|
|
23537
|
+
hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
|
|
23538
|
+
// protocols that can allow "unsafe" and "unwise" chars.
|
|
23539
|
+
unsafeProtocol = {
|
|
23540
|
+
'javascript': true,
|
|
23541
|
+
'javascript:': true
|
|
23542
|
+
},
|
|
23543
|
+
// protocols that never have a hostname.
|
|
23544
|
+
hostlessProtocol = {
|
|
23545
|
+
'javascript': true,
|
|
23546
|
+
'javascript:': true
|
|
23547
|
+
},
|
|
23548
|
+
// protocols that always contain a // bit.
|
|
23549
|
+
slashedProtocol = {
|
|
23550
|
+
'http': true,
|
|
23551
|
+
'https': true,
|
|
23552
|
+
'ftp': true,
|
|
23553
|
+
'gopher': true,
|
|
23554
|
+
'file': true,
|
|
23555
|
+
'http:': true,
|
|
23556
|
+
'https:': true,
|
|
23557
|
+
'ftp:': true,
|
|
23558
|
+
'gopher:': true,
|
|
23559
|
+
'file:': true
|
|
23560
|
+
},
|
|
23561
|
+
querystring = require('querystring');
|
|
23562
|
+
|
|
23563
|
+
function urlParse(url, parseQueryString, slashesDenoteHost) {
|
|
23564
|
+
if (url && util.isObject(url) && url instanceof Url) return url;
|
|
23565
|
+
|
|
23566
|
+
var u = new Url;
|
|
23567
|
+
u.parse(url, parseQueryString, slashesDenoteHost);
|
|
23568
|
+
return u;
|
|
23569
|
+
}
|
|
23570
|
+
|
|
23571
|
+
Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
|
|
23572
|
+
if (!util.isString(url)) {
|
|
23573
|
+
throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
|
|
23574
|
+
}
|
|
23575
|
+
|
|
23576
|
+
// Copy chrome, IE, opera backslash-handling behavior.
|
|
23577
|
+
// Back slashes before the query string get converted to forward slashes
|
|
23578
|
+
// See: https://code.google.com/p/chromium/issues/detail?id=25916
|
|
23579
|
+
var queryIndex = url.indexOf('?'),
|
|
23580
|
+
splitter =
|
|
23581
|
+
(queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
|
|
23582
|
+
uSplit = url.split(splitter),
|
|
23583
|
+
slashRegex = /\\/g;
|
|
23584
|
+
uSplit[0] = uSplit[0].replace(slashRegex, '/');
|
|
23585
|
+
url = uSplit.join(splitter);
|
|
23586
|
+
|
|
23587
|
+
var rest = url;
|
|
23588
|
+
|
|
23589
|
+
// trim before proceeding.
|
|
23590
|
+
// This is to support parse stuff like " http://foo.com \n"
|
|
23591
|
+
rest = rest.trim();
|
|
23592
|
+
|
|
23593
|
+
if (!slashesDenoteHost && url.split('#').length === 1) {
|
|
23594
|
+
// Try fast path regexp
|
|
23595
|
+
var simplePath = simplePathPattern.exec(rest);
|
|
23596
|
+
if (simplePath) {
|
|
23597
|
+
this.path = rest;
|
|
23598
|
+
this.href = rest;
|
|
23599
|
+
this.pathname = simplePath[1];
|
|
23600
|
+
if (simplePath[2]) {
|
|
23601
|
+
this.search = simplePath[2];
|
|
23602
|
+
if (parseQueryString) {
|
|
23603
|
+
this.query = querystring.parse(this.search.substr(1));
|
|
23604
|
+
} else {
|
|
23605
|
+
this.query = this.search.substr(1);
|
|
23606
|
+
}
|
|
23607
|
+
} else if (parseQueryString) {
|
|
23608
|
+
this.search = '';
|
|
23609
|
+
this.query = {};
|
|
23610
|
+
}
|
|
23611
|
+
return this;
|
|
23612
|
+
}
|
|
23613
|
+
}
|
|
23614
|
+
|
|
23615
|
+
var proto = protocolPattern.exec(rest);
|
|
23616
|
+
if (proto) {
|
|
23617
|
+
proto = proto[0];
|
|
23618
|
+
var lowerProto = proto.toLowerCase();
|
|
23619
|
+
this.protocol = lowerProto;
|
|
23620
|
+
rest = rest.substr(proto.length);
|
|
23621
|
+
}
|
|
23622
|
+
|
|
23623
|
+
// figure out if it's got a host
|
|
23624
|
+
// user@server is *always* interpreted as a hostname, and url
|
|
23625
|
+
// resolution will treat //foo/bar as host=foo,path=bar because that's
|
|
23626
|
+
// how the browser resolves relative URLs.
|
|
23627
|
+
if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
|
|
23628
|
+
var slashes = rest.substr(0, 2) === '//';
|
|
23629
|
+
if (slashes && !(proto && hostlessProtocol[proto])) {
|
|
23630
|
+
rest = rest.substr(2);
|
|
23631
|
+
this.slashes = true;
|
|
23632
|
+
}
|
|
23633
|
+
}
|
|
23634
|
+
|
|
23635
|
+
if (!hostlessProtocol[proto] &&
|
|
23636
|
+
(slashes || (proto && !slashedProtocol[proto]))) {
|
|
23637
|
+
|
|
23638
|
+
// there's a hostname.
|
|
23639
|
+
// the first instance of /, ?, ;, or # ends the host.
|
|
23640
|
+
//
|
|
23641
|
+
// If there is an @ in the hostname, then non-host chars *are* allowed
|
|
23642
|
+
// to the left of the last @ sign, unless some host-ending character
|
|
23643
|
+
// comes *before* the @-sign.
|
|
23644
|
+
// URLs are obnoxious.
|
|
23645
|
+
//
|
|
23646
|
+
// ex:
|
|
23647
|
+
// http://a@b@c/ => user:a@b host:c
|
|
23648
|
+
// http://a@b?@c => user:a host:c path:/?@c
|
|
23649
|
+
|
|
23650
|
+
// v0.12 TODO(isaacs): This is not quite how Chrome does things.
|
|
23651
|
+
// Review our test case against browsers more comprehensively.
|
|
23652
|
+
|
|
23653
|
+
// find the first instance of any hostEndingChars
|
|
23654
|
+
var hostEnd = -1;
|
|
23655
|
+
for (var i = 0; i < hostEndingChars.length; i++) {
|
|
23656
|
+
var hec = rest.indexOf(hostEndingChars[i]);
|
|
23657
|
+
if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
|
|
23658
|
+
hostEnd = hec;
|
|
23659
|
+
}
|
|
23660
|
+
|
|
23661
|
+
// at this point, either we have an explicit point where the
|
|
23662
|
+
// auth portion cannot go past, or the last @ char is the decider.
|
|
23663
|
+
var auth, atSign;
|
|
23664
|
+
if (hostEnd === -1) {
|
|
23665
|
+
// atSign can be anywhere.
|
|
23666
|
+
atSign = rest.lastIndexOf('@');
|
|
23667
|
+
} else {
|
|
23668
|
+
// atSign must be in auth portion.
|
|
23669
|
+
// http://a@b/c@d => host:b auth:a path:/c@d
|
|
23670
|
+
atSign = rest.lastIndexOf('@', hostEnd);
|
|
23671
|
+
}
|
|
23672
|
+
|
|
23673
|
+
// Now we have a portion which is definitely the auth.
|
|
23674
|
+
// Pull that off.
|
|
23675
|
+
if (atSign !== -1) {
|
|
23676
|
+
auth = rest.slice(0, atSign);
|
|
23677
|
+
rest = rest.slice(atSign + 1);
|
|
23678
|
+
this.auth = decodeURIComponent(auth);
|
|
23679
|
+
}
|
|
23680
|
+
|
|
23681
|
+
// the host is the remaining to the left of the first non-host char
|
|
23682
|
+
hostEnd = -1;
|
|
23683
|
+
for (var i = 0; i < nonHostChars.length; i++) {
|
|
23684
|
+
var hec = rest.indexOf(nonHostChars[i]);
|
|
23685
|
+
if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
|
|
23686
|
+
hostEnd = hec;
|
|
23687
|
+
}
|
|
23688
|
+
// if we still have not hit it, then the entire thing is a host.
|
|
23689
|
+
if (hostEnd === -1)
|
|
23690
|
+
hostEnd = rest.length;
|
|
23691
|
+
|
|
23692
|
+
this.host = rest.slice(0, hostEnd);
|
|
23693
|
+
rest = rest.slice(hostEnd);
|
|
23694
|
+
|
|
23695
|
+
// pull out port.
|
|
23696
|
+
this.parseHost();
|
|
23697
|
+
|
|
23698
|
+
// we've indicated that there is a hostname,
|
|
23699
|
+
// so even if it's empty, it has to be present.
|
|
23700
|
+
this.hostname = this.hostname || '';
|
|
23701
|
+
|
|
23702
|
+
// if hostname begins with [ and ends with ]
|
|
23703
|
+
// assume that it's an IPv6 address.
|
|
23704
|
+
var ipv6Hostname = this.hostname[0] === '[' &&
|
|
23705
|
+
this.hostname[this.hostname.length - 1] === ']';
|
|
23706
|
+
|
|
23707
|
+
// validate a little.
|
|
23708
|
+
if (!ipv6Hostname) {
|
|
23709
|
+
var hostparts = this.hostname.split(/\./);
|
|
23710
|
+
for (var i = 0, l = hostparts.length; i < l; i++) {
|
|
23711
|
+
var part = hostparts[i];
|
|
23712
|
+
if (!part) continue;
|
|
23713
|
+
if (!part.match(hostnamePartPattern)) {
|
|
23714
|
+
var newpart = '';
|
|
23715
|
+
for (var j = 0, k = part.length; j < k; j++) {
|
|
23716
|
+
if (part.charCodeAt(j) > 127) {
|
|
23717
|
+
// we replace non-ASCII char with a temporary placeholder
|
|
23718
|
+
// we need this to make sure size of hostname is not
|
|
23719
|
+
// broken by replacing non-ASCII by nothing
|
|
23720
|
+
newpart += 'x';
|
|
23721
|
+
} else {
|
|
23722
|
+
newpart += part[j];
|
|
23723
|
+
}
|
|
23724
|
+
}
|
|
23725
|
+
// we test again with ASCII char only
|
|
23726
|
+
if (!newpart.match(hostnamePartPattern)) {
|
|
23727
|
+
var validParts = hostparts.slice(0, i);
|
|
23728
|
+
var notHost = hostparts.slice(i + 1);
|
|
23729
|
+
var bit = part.match(hostnamePartStart);
|
|
23730
|
+
if (bit) {
|
|
23731
|
+
validParts.push(bit[1]);
|
|
23732
|
+
notHost.unshift(bit[2]);
|
|
23733
|
+
}
|
|
23734
|
+
if (notHost.length) {
|
|
23735
|
+
rest = '/' + notHost.join('.') + rest;
|
|
23736
|
+
}
|
|
23737
|
+
this.hostname = validParts.join('.');
|
|
23738
|
+
break;
|
|
23739
|
+
}
|
|
23740
|
+
}
|
|
23741
|
+
}
|
|
23742
|
+
}
|
|
23743
|
+
|
|
23744
|
+
if (this.hostname.length > hostnameMaxLen) {
|
|
23745
|
+
this.hostname = '';
|
|
23746
|
+
} else {
|
|
23747
|
+
// hostnames are always lower case.
|
|
23748
|
+
this.hostname = this.hostname.toLowerCase();
|
|
23749
|
+
}
|
|
23750
|
+
|
|
23751
|
+
if (!ipv6Hostname) {
|
|
23752
|
+
// IDNA Support: Returns a punycoded representation of "domain".
|
|
23753
|
+
// It only converts parts of the domain name that
|
|
23754
|
+
// have non-ASCII characters, i.e. it doesn't matter if
|
|
23755
|
+
// you call it with a domain that already is ASCII-only.
|
|
23756
|
+
this.hostname = punycode.toASCII(this.hostname);
|
|
23757
|
+
}
|
|
23758
|
+
|
|
23759
|
+
var p = this.port ? ':' + this.port : '';
|
|
23760
|
+
var h = this.hostname || '';
|
|
23761
|
+
this.host = h + p;
|
|
23762
|
+
this.href += this.host;
|
|
23763
|
+
|
|
23764
|
+
// strip [ and ] from the hostname
|
|
23765
|
+
// the host field still retains them, though
|
|
23766
|
+
if (ipv6Hostname) {
|
|
23767
|
+
this.hostname = this.hostname.substr(1, this.hostname.length - 2);
|
|
23768
|
+
if (rest[0] !== '/') {
|
|
23769
|
+
rest = '/' + rest;
|
|
23770
|
+
}
|
|
23771
|
+
}
|
|
23772
|
+
}
|
|
23773
|
+
|
|
23774
|
+
// now rest is set to the post-host stuff.
|
|
23775
|
+
// chop off any delim chars.
|
|
23776
|
+
if (!unsafeProtocol[lowerProto]) {
|
|
23777
|
+
|
|
23778
|
+
// First, make 100% sure that any "autoEscape" chars get
|
|
23779
|
+
// escaped, even if encodeURIComponent doesn't think they
|
|
23780
|
+
// need to be.
|
|
23781
|
+
for (var i = 0, l = autoEscape.length; i < l; i++) {
|
|
23782
|
+
var ae = autoEscape[i];
|
|
23783
|
+
if (rest.indexOf(ae) === -1)
|
|
23784
|
+
continue;
|
|
23785
|
+
var esc = encodeURIComponent(ae);
|
|
23786
|
+
if (esc === ae) {
|
|
23787
|
+
esc = escape(ae);
|
|
23788
|
+
}
|
|
23789
|
+
rest = rest.split(ae).join(esc);
|
|
23790
|
+
}
|
|
23791
|
+
}
|
|
23792
|
+
|
|
23793
|
+
|
|
23794
|
+
// chop off from the tail first.
|
|
23795
|
+
var hash = rest.indexOf('#');
|
|
23796
|
+
if (hash !== -1) {
|
|
23797
|
+
// got a fragment string.
|
|
23798
|
+
this.hash = rest.substr(hash);
|
|
23799
|
+
rest = rest.slice(0, hash);
|
|
23800
|
+
}
|
|
23801
|
+
var qm = rest.indexOf('?');
|
|
23802
|
+
if (qm !== -1) {
|
|
23803
|
+
this.search = rest.substr(qm);
|
|
23804
|
+
this.query = rest.substr(qm + 1);
|
|
23805
|
+
if (parseQueryString) {
|
|
23806
|
+
this.query = querystring.parse(this.query);
|
|
23807
|
+
}
|
|
23808
|
+
rest = rest.slice(0, qm);
|
|
23809
|
+
} else if (parseQueryString) {
|
|
23810
|
+
// no query string, but parseQueryString still requested
|
|
23811
|
+
this.search = '';
|
|
23812
|
+
this.query = {};
|
|
23813
|
+
}
|
|
23814
|
+
if (rest) this.pathname = rest;
|
|
23815
|
+
if (slashedProtocol[lowerProto] &&
|
|
23816
|
+
this.hostname && !this.pathname) {
|
|
23817
|
+
this.pathname = '/';
|
|
23818
|
+
}
|
|
23819
|
+
|
|
23820
|
+
//to support http.request
|
|
23821
|
+
if (this.pathname || this.search) {
|
|
23822
|
+
var p = this.pathname || '';
|
|
23823
|
+
var s = this.search || '';
|
|
23824
|
+
this.path = p + s;
|
|
23825
|
+
}
|
|
23826
|
+
|
|
23827
|
+
// finally, reconstruct the href based on what has been validated.
|
|
23828
|
+
this.href = this.format();
|
|
23829
|
+
return this;
|
|
23830
|
+
};
|
|
23831
|
+
|
|
23832
|
+
// format a parsed object into a url string
|
|
23833
|
+
function urlFormat(obj) {
|
|
23834
|
+
// ensure it's an object, and not a string url.
|
|
23835
|
+
// If it's an obj, this is a no-op.
|
|
23836
|
+
// this way, you can call url_format() on strings
|
|
23837
|
+
// to clean up potentially wonky urls.
|
|
23838
|
+
if (util.isString(obj)) obj = urlParse(obj);
|
|
23839
|
+
if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
|
|
23840
|
+
return obj.format();
|
|
23841
|
+
}
|
|
23842
|
+
|
|
23843
|
+
Url.prototype.format = function() {
|
|
23844
|
+
var auth = this.auth || '';
|
|
23845
|
+
if (auth) {
|
|
23846
|
+
auth = encodeURIComponent(auth);
|
|
23847
|
+
auth = auth.replace(/%3A/i, ':');
|
|
23848
|
+
auth += '@';
|
|
23849
|
+
}
|
|
23850
|
+
|
|
23851
|
+
var protocol = this.protocol || '',
|
|
23852
|
+
pathname = this.pathname || '',
|
|
23853
|
+
hash = this.hash || '',
|
|
23854
|
+
host = false,
|
|
23855
|
+
query = '';
|
|
23856
|
+
|
|
23857
|
+
if (this.host) {
|
|
23858
|
+
host = auth + this.host;
|
|
23859
|
+
} else if (this.hostname) {
|
|
23860
|
+
host = auth + (this.hostname.indexOf(':') === -1 ?
|
|
23861
|
+
this.hostname :
|
|
23862
|
+
'[' + this.hostname + ']');
|
|
23863
|
+
if (this.port) {
|
|
23864
|
+
host += ':' + this.port;
|
|
23865
|
+
}
|
|
23866
|
+
}
|
|
23867
|
+
|
|
23868
|
+
if (this.query &&
|
|
23869
|
+
util.isObject(this.query) &&
|
|
23870
|
+
Object.keys(this.query).length) {
|
|
23871
|
+
query = querystring.stringify(this.query);
|
|
23872
|
+
}
|
|
23873
|
+
|
|
23874
|
+
var search = this.search || (query && ('?' + query)) || '';
|
|
23875
|
+
|
|
23876
|
+
if (protocol && protocol.substr(-1) !== ':') protocol += ':';
|
|
23877
|
+
|
|
23878
|
+
// only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
|
|
23879
|
+
// unless they had them to begin with.
|
|
23880
|
+
if (this.slashes ||
|
|
23881
|
+
(!protocol || slashedProtocol[protocol]) && host !== false) {
|
|
23882
|
+
host = '//' + (host || '');
|
|
23883
|
+
if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
|
|
23884
|
+
} else if (!host) {
|
|
23885
|
+
host = '';
|
|
23886
|
+
}
|
|
23887
|
+
|
|
23888
|
+
if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
|
|
23889
|
+
if (search && search.charAt(0) !== '?') search = '?' + search;
|
|
23890
|
+
|
|
23891
|
+
pathname = pathname.replace(/[?#]/g, function(match) {
|
|
23892
|
+
return encodeURIComponent(match);
|
|
23893
|
+
});
|
|
23894
|
+
search = search.replace('#', '%23');
|
|
23895
|
+
|
|
23896
|
+
return protocol + host + pathname + search + hash;
|
|
23897
|
+
};
|
|
23898
|
+
|
|
23899
|
+
function urlResolve(source, relative) {
|
|
23900
|
+
return urlParse(source, false, true).resolve(relative);
|
|
23901
|
+
}
|
|
23902
|
+
|
|
23903
|
+
Url.prototype.resolve = function(relative) {
|
|
23904
|
+
return this.resolveObject(urlParse(relative, false, true)).format();
|
|
23905
|
+
};
|
|
23906
|
+
|
|
23907
|
+
function urlResolveObject(source, relative) {
|
|
23908
|
+
if (!source) return relative;
|
|
23909
|
+
return urlParse(source, false, true).resolveObject(relative);
|
|
23910
|
+
}
|
|
23911
|
+
|
|
23912
|
+
Url.prototype.resolveObject = function(relative) {
|
|
23913
|
+
if (util.isString(relative)) {
|
|
23914
|
+
var rel = new Url();
|
|
23915
|
+
rel.parse(relative, false, true);
|
|
23916
|
+
relative = rel;
|
|
23917
|
+
}
|
|
23918
|
+
|
|
23919
|
+
var result = new Url();
|
|
23920
|
+
var tkeys = Object.keys(this);
|
|
23921
|
+
for (var tk = 0; tk < tkeys.length; tk++) {
|
|
23922
|
+
var tkey = tkeys[tk];
|
|
23923
|
+
result[tkey] = this[tkey];
|
|
23924
|
+
}
|
|
23925
|
+
|
|
23926
|
+
// hash is always overridden, no matter what.
|
|
23927
|
+
// even href="" will remove it.
|
|
23928
|
+
result.hash = relative.hash;
|
|
23929
|
+
|
|
23930
|
+
// if the relative url is empty, then there's nothing left to do here.
|
|
23931
|
+
if (relative.href === '') {
|
|
23932
|
+
result.href = result.format();
|
|
23933
|
+
return result;
|
|
23934
|
+
}
|
|
23935
|
+
|
|
23936
|
+
// hrefs like //foo/bar always cut to the protocol.
|
|
23937
|
+
if (relative.slashes && !relative.protocol) {
|
|
23938
|
+
// take everything except the protocol from relative
|
|
23939
|
+
var rkeys = Object.keys(relative);
|
|
23940
|
+
for (var rk = 0; rk < rkeys.length; rk++) {
|
|
23941
|
+
var rkey = rkeys[rk];
|
|
23942
|
+
if (rkey !== 'protocol')
|
|
23943
|
+
result[rkey] = relative[rkey];
|
|
23944
|
+
}
|
|
23945
|
+
|
|
23946
|
+
//urlParse appends trailing / to urls like http://www.example.com
|
|
23947
|
+
if (slashedProtocol[result.protocol] &&
|
|
23948
|
+
result.hostname && !result.pathname) {
|
|
23949
|
+
result.path = result.pathname = '/';
|
|
23950
|
+
}
|
|
23951
|
+
|
|
23952
|
+
result.href = result.format();
|
|
23953
|
+
return result;
|
|
23954
|
+
}
|
|
23955
|
+
|
|
23956
|
+
if (relative.protocol && relative.protocol !== result.protocol) {
|
|
23957
|
+
// if it's a known url protocol, then changing
|
|
23958
|
+
// the protocol does weird things
|
|
23959
|
+
// first, if it's not file:, then we MUST have a host,
|
|
23960
|
+
// and if there was a path
|
|
23961
|
+
// to begin with, then we MUST have a path.
|
|
23962
|
+
// if it is file:, then the host is dropped,
|
|
23963
|
+
// because that's known to be hostless.
|
|
23964
|
+
// anything else is assumed to be absolute.
|
|
23965
|
+
if (!slashedProtocol[relative.protocol]) {
|
|
23966
|
+
var keys = Object.keys(relative);
|
|
23967
|
+
for (var v = 0; v < keys.length; v++) {
|
|
23968
|
+
var k = keys[v];
|
|
23969
|
+
result[k] = relative[k];
|
|
23970
|
+
}
|
|
23971
|
+
result.href = result.format();
|
|
23972
|
+
return result;
|
|
23973
|
+
}
|
|
23974
|
+
|
|
23975
|
+
result.protocol = relative.protocol;
|
|
23976
|
+
if (!relative.host && !hostlessProtocol[relative.protocol]) {
|
|
23977
|
+
var relPath = (relative.pathname || '').split('/');
|
|
23978
|
+
while (relPath.length && !(relative.host = relPath.shift()));
|
|
23979
|
+
if (!relative.host) relative.host = '';
|
|
23980
|
+
if (!relative.hostname) relative.hostname = '';
|
|
23981
|
+
if (relPath[0] !== '') relPath.unshift('');
|
|
23982
|
+
if (relPath.length < 2) relPath.unshift('');
|
|
23983
|
+
result.pathname = relPath.join('/');
|
|
23984
|
+
} else {
|
|
23985
|
+
result.pathname = relative.pathname;
|
|
23986
|
+
}
|
|
23987
|
+
result.search = relative.search;
|
|
23988
|
+
result.query = relative.query;
|
|
23989
|
+
result.host = relative.host || '';
|
|
23990
|
+
result.auth = relative.auth;
|
|
23991
|
+
result.hostname = relative.hostname || relative.host;
|
|
23992
|
+
result.port = relative.port;
|
|
23993
|
+
// to support http.request
|
|
23994
|
+
if (result.pathname || result.search) {
|
|
23995
|
+
var p = result.pathname || '';
|
|
23996
|
+
var s = result.search || '';
|
|
23997
|
+
result.path = p + s;
|
|
23998
|
+
}
|
|
23999
|
+
result.slashes = result.slashes || relative.slashes;
|
|
24000
|
+
result.href = result.format();
|
|
24001
|
+
return result;
|
|
24002
|
+
}
|
|
24003
|
+
|
|
24004
|
+
var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
|
|
24005
|
+
isRelAbs = (
|
|
24006
|
+
relative.host ||
|
|
24007
|
+
relative.pathname && relative.pathname.charAt(0) === '/'
|
|
24008
|
+
),
|
|
24009
|
+
mustEndAbs = (isRelAbs || isSourceAbs ||
|
|
24010
|
+
(result.host && relative.pathname)),
|
|
24011
|
+
removeAllDots = mustEndAbs,
|
|
24012
|
+
srcPath = result.pathname && result.pathname.split('/') || [],
|
|
24013
|
+
relPath = relative.pathname && relative.pathname.split('/') || [],
|
|
24014
|
+
psychotic = result.protocol && !slashedProtocol[result.protocol];
|
|
24015
|
+
|
|
24016
|
+
// if the url is a non-slashed url, then relative
|
|
24017
|
+
// links like ../.. should be able
|
|
24018
|
+
// to crawl up to the hostname, as well. This is strange.
|
|
24019
|
+
// result.protocol has already been set by now.
|
|
24020
|
+
// Later on, put the first path part into the host field.
|
|
24021
|
+
if (psychotic) {
|
|
24022
|
+
result.hostname = '';
|
|
24023
|
+
result.port = null;
|
|
24024
|
+
if (result.host) {
|
|
24025
|
+
if (srcPath[0] === '') srcPath[0] = result.host;
|
|
24026
|
+
else srcPath.unshift(result.host);
|
|
24027
|
+
}
|
|
24028
|
+
result.host = '';
|
|
24029
|
+
if (relative.protocol) {
|
|
24030
|
+
relative.hostname = null;
|
|
24031
|
+
relative.port = null;
|
|
24032
|
+
if (relative.host) {
|
|
24033
|
+
if (relPath[0] === '') relPath[0] = relative.host;
|
|
24034
|
+
else relPath.unshift(relative.host);
|
|
24035
|
+
}
|
|
24036
|
+
relative.host = null;
|
|
24037
|
+
}
|
|
24038
|
+
mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
|
|
24039
|
+
}
|
|
24040
|
+
|
|
24041
|
+
if (isRelAbs) {
|
|
24042
|
+
// it's absolute.
|
|
24043
|
+
result.host = (relative.host || relative.host === '') ?
|
|
24044
|
+
relative.host : result.host;
|
|
24045
|
+
result.hostname = (relative.hostname || relative.hostname === '') ?
|
|
24046
|
+
relative.hostname : result.hostname;
|
|
24047
|
+
result.search = relative.search;
|
|
24048
|
+
result.query = relative.query;
|
|
24049
|
+
srcPath = relPath;
|
|
24050
|
+
// fall through to the dot-handling below.
|
|
24051
|
+
} else if (relPath.length) {
|
|
24052
|
+
// it's relative
|
|
24053
|
+
// throw away the existing file, and take the new path instead.
|
|
24054
|
+
if (!srcPath) srcPath = [];
|
|
24055
|
+
srcPath.pop();
|
|
24056
|
+
srcPath = srcPath.concat(relPath);
|
|
24057
|
+
result.search = relative.search;
|
|
24058
|
+
result.query = relative.query;
|
|
24059
|
+
} else if (!util.isNullOrUndefined(relative.search)) {
|
|
24060
|
+
// just pull out the search.
|
|
24061
|
+
// like href='?foo'.
|
|
24062
|
+
// Put this after the other two cases because it simplifies the booleans
|
|
24063
|
+
if (psychotic) {
|
|
24064
|
+
result.hostname = result.host = srcPath.shift();
|
|
24065
|
+
//occationaly the auth can get stuck only in host
|
|
24066
|
+
//this especially happens in cases like
|
|
24067
|
+
//url.resolveObject('mailto:local1@domain1', 'local2@domain2')
|
|
24068
|
+
var authInHost = result.host && result.host.indexOf('@') > 0 ?
|
|
24069
|
+
result.host.split('@') : false;
|
|
24070
|
+
if (authInHost) {
|
|
24071
|
+
result.auth = authInHost.shift();
|
|
24072
|
+
result.host = result.hostname = authInHost.shift();
|
|
24073
|
+
}
|
|
24074
|
+
}
|
|
24075
|
+
result.search = relative.search;
|
|
24076
|
+
result.query = relative.query;
|
|
24077
|
+
//to support http.request
|
|
24078
|
+
if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
|
|
24079
|
+
result.path = (result.pathname ? result.pathname : '') +
|
|
24080
|
+
(result.search ? result.search : '');
|
|
24081
|
+
}
|
|
24082
|
+
result.href = result.format();
|
|
24083
|
+
return result;
|
|
24084
|
+
}
|
|
24085
|
+
|
|
24086
|
+
if (!srcPath.length) {
|
|
24087
|
+
// no path at all. easy.
|
|
24088
|
+
// we've already handled the other stuff above.
|
|
24089
|
+
result.pathname = null;
|
|
24090
|
+
//to support http.request
|
|
24091
|
+
if (result.search) {
|
|
24092
|
+
result.path = '/' + result.search;
|
|
24093
|
+
} else {
|
|
24094
|
+
result.path = null;
|
|
24095
|
+
}
|
|
24096
|
+
result.href = result.format();
|
|
24097
|
+
return result;
|
|
24098
|
+
}
|
|
24099
|
+
|
|
24100
|
+
// if a url ENDs in . or .., then it must get a trailing slash.
|
|
24101
|
+
// however, if it ends in anything else non-slashy,
|
|
24102
|
+
// then it must NOT get a trailing slash.
|
|
24103
|
+
var last = srcPath.slice(-1)[0];
|
|
24104
|
+
var hasTrailingSlash = (
|
|
24105
|
+
(result.host || relative.host || srcPath.length > 1) &&
|
|
24106
|
+
(last === '.' || last === '..') || last === '');
|
|
24107
|
+
|
|
24108
|
+
// strip single dots, resolve double dots to parent dir
|
|
24109
|
+
// if the path tries to go above the root, `up` ends up > 0
|
|
24110
|
+
var up = 0;
|
|
24111
|
+
for (var i = srcPath.length; i >= 0; i--) {
|
|
24112
|
+
last = srcPath[i];
|
|
24113
|
+
if (last === '.') {
|
|
24114
|
+
srcPath.splice(i, 1);
|
|
24115
|
+
} else if (last === '..') {
|
|
24116
|
+
srcPath.splice(i, 1);
|
|
24117
|
+
up++;
|
|
24118
|
+
} else if (up) {
|
|
24119
|
+
srcPath.splice(i, 1);
|
|
24120
|
+
up--;
|
|
24121
|
+
}
|
|
24122
|
+
}
|
|
24123
|
+
|
|
24124
|
+
// if the path is allowed to go above the root, restore leading ..s
|
|
24125
|
+
if (!mustEndAbs && !removeAllDots) {
|
|
24126
|
+
for (; up--; up) {
|
|
24127
|
+
srcPath.unshift('..');
|
|
24128
|
+
}
|
|
24129
|
+
}
|
|
24130
|
+
|
|
24131
|
+
if (mustEndAbs && srcPath[0] !== '' &&
|
|
24132
|
+
(!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
|
|
24133
|
+
srcPath.unshift('');
|
|
24134
|
+
}
|
|
24135
|
+
|
|
24136
|
+
if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
|
|
24137
|
+
srcPath.push('');
|
|
24138
|
+
}
|
|
24139
|
+
|
|
24140
|
+
var isAbsolute = srcPath[0] === '' ||
|
|
24141
|
+
(srcPath[0] && srcPath[0].charAt(0) === '/');
|
|
24142
|
+
|
|
24143
|
+
// put the host back
|
|
24144
|
+
if (psychotic) {
|
|
24145
|
+
result.hostname = result.host = isAbsolute ? '' :
|
|
24146
|
+
srcPath.length ? srcPath.shift() : '';
|
|
24147
|
+
//occationaly the auth can get stuck only in host
|
|
24148
|
+
//this especially happens in cases like
|
|
24149
|
+
//url.resolveObject('mailto:local1@domain1', 'local2@domain2')
|
|
24150
|
+
var authInHost = result.host && result.host.indexOf('@') > 0 ?
|
|
24151
|
+
result.host.split('@') : false;
|
|
24152
|
+
if (authInHost) {
|
|
24153
|
+
result.auth = authInHost.shift();
|
|
24154
|
+
result.host = result.hostname = authInHost.shift();
|
|
24155
|
+
}
|
|
24156
|
+
}
|
|
24157
|
+
|
|
24158
|
+
mustEndAbs = mustEndAbs || (result.host && srcPath.length);
|
|
24159
|
+
|
|
24160
|
+
if (mustEndAbs && !isAbsolute) {
|
|
24161
|
+
srcPath.unshift('');
|
|
24162
|
+
}
|
|
24163
|
+
|
|
24164
|
+
if (!srcPath.length) {
|
|
24165
|
+
result.pathname = null;
|
|
24166
|
+
result.path = null;
|
|
24167
|
+
} else {
|
|
24168
|
+
result.pathname = srcPath.join('/');
|
|
24169
|
+
}
|
|
24170
|
+
|
|
24171
|
+
//to support request.http
|
|
24172
|
+
if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
|
|
24173
|
+
result.path = (result.pathname ? result.pathname : '') +
|
|
24174
|
+
(result.search ? result.search : '');
|
|
24175
|
+
}
|
|
24176
|
+
result.auth = relative.auth || result.auth;
|
|
24177
|
+
result.slashes = result.slashes || relative.slashes;
|
|
24178
|
+
result.href = result.format();
|
|
24179
|
+
return result;
|
|
24180
|
+
};
|
|
24181
|
+
|
|
24182
|
+
Url.prototype.parseHost = function() {
|
|
24183
|
+
var host = this.host;
|
|
24184
|
+
var port = portPattern.exec(host);
|
|
24185
|
+
if (port) {
|
|
24186
|
+
port = port[0];
|
|
24187
|
+
if (port !== ':') {
|
|
24188
|
+
this.port = port.substr(1);
|
|
24189
|
+
}
|
|
24190
|
+
host = host.substr(0, host.length - port.length);
|
|
24191
|
+
}
|
|
24192
|
+
if (host) this.hostname = host;
|
|
24193
|
+
};
|
|
24194
|
+
|
|
24195
|
+
},{"./util":110,"punycode":86,"querystring":89}],110:[function(require,module,exports){
|
|
24196
|
+
'use strict';
|
|
24197
|
+
|
|
24198
|
+
module.exports = {
|
|
24199
|
+
isString: function(arg) {
|
|
24200
|
+
return typeof(arg) === 'string';
|
|
24201
|
+
},
|
|
24202
|
+
isObject: function(arg) {
|
|
24203
|
+
return typeof(arg) === 'object' && arg !== null;
|
|
24204
|
+
},
|
|
24205
|
+
isNull: function(arg) {
|
|
24206
|
+
return arg === null;
|
|
24207
|
+
},
|
|
24208
|
+
isNullOrUndefined: function(arg) {
|
|
24209
|
+
return arg == null;
|
|
24210
|
+
}
|
|
24211
|
+
};
|
|
24212
|
+
|
|
24213
|
+
},{}],111:[function(require,module,exports){
|
|
22411
24214
|
(function (global){
|
|
22412
24215
|
|
|
22413
24216
|
/**
|
|
@@ -22478,7 +24281,7 @@ function config (name) {
|
|
|
22478
24281
|
}
|
|
22479
24282
|
|
|
22480
24283
|
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
22481
|
-
},{}],
|
|
24284
|
+
},{}],112:[function(require,module,exports){
|
|
22482
24285
|
module.exports = extend
|
|
22483
24286
|
|
|
22484
24287
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|