axios 0.26.1 → 0.27.0
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/CHANGELOG.md +36 -12
- package/README.md +114 -32
- package/dist/axios.js +1828 -141
- package/dist/axios.map +1 -1
- package/dist/axios.min.js +3 -1
- package/dist/axios.min.map +1 -1
- package/index.d.ts +37 -4
- package/lib/adapters/http.js +45 -27
- package/lib/adapters/xhr.js +21 -11
- package/lib/axios.js +8 -1
- package/lib/cancel/CancelToken.js +3 -3
- package/lib/cancel/CanceledError.js +22 -0
- package/lib/core/Axios.js +20 -8
- package/lib/core/AxiosError.js +86 -0
- package/lib/core/dispatchRequest.js +3 -3
- package/lib/core/mergeConfig.js +1 -0
- package/lib/core/settle.js +3 -3
- package/lib/defaults/env/FormData.js +2 -0
- package/lib/defaults/index.js +18 -3
- package/lib/env/data.js +1 -1
- package/lib/helpers/null.js +2 -0
- package/lib/helpers/toFormData.js +63 -46
- package/lib/helpers/validator.js +8 -4
- package/lib/utils.js +166 -27
- package/package.json +26 -22
- package/lib/cancel/Cancel.js +0 -19
- package/lib/core/createError.js +0 -18
- package/lib/core/enhanceError.js +0 -43
package/dist/axios.js
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
/* axios v0.27.0 | (c) 2022 by Matt Zabriskie */
|
2
|
+
/* axios v0.26.1 | (c) 2022 by Matt Zabriskie */
|
1
3
|
(function webpackUniversalModuleDefinition(root, factory) {
|
2
4
|
if(typeof exports === 'object' && typeof module === 'object')
|
3
5
|
module.exports = factory();
|
@@ -124,9 +126,10 @@ var buildURL = __webpack_require__(/*! ./../helpers/buildURL */ "./lib/helpers/b
|
|
124
126
|
var buildFullPath = __webpack_require__(/*! ../core/buildFullPath */ "./lib/core/buildFullPath.js");
|
125
127
|
var parseHeaders = __webpack_require__(/*! ./../helpers/parseHeaders */ "./lib/helpers/parseHeaders.js");
|
126
128
|
var isURLSameOrigin = __webpack_require__(/*! ./../helpers/isURLSameOrigin */ "./lib/helpers/isURLSameOrigin.js");
|
127
|
-
var
|
129
|
+
var url = __webpack_require__(/*! url */ "./node_modules/url/url.js");
|
128
130
|
var transitionalDefaults = __webpack_require__(/*! ../defaults/transitional */ "./lib/defaults/transitional.js");
|
129
|
-
var
|
131
|
+
var AxiosError = __webpack_require__(/*! ../core/AxiosError */ "./lib/core/AxiosError.js");
|
132
|
+
var CanceledError = __webpack_require__(/*! ../cancel/CanceledError */ "./lib/cancel/CanceledError.js");
|
130
133
|
|
131
134
|
module.exports = function xhrAdapter(config) {
|
132
135
|
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
@@ -158,6 +161,9 @@ module.exports = function xhrAdapter(config) {
|
|
158
161
|
}
|
159
162
|
|
160
163
|
var fullPath = buildFullPath(config.baseURL, config.url);
|
164
|
+
var parsed = url.parse(fullPath);
|
165
|
+
var protocol = utils.getProtocol(parsed.protocol);
|
166
|
+
|
161
167
|
request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
|
162
168
|
|
163
169
|
// Set the request timeout in MS
|
@@ -221,7 +227,7 @@ module.exports = function xhrAdapter(config) {
|
|
221
227
|
return;
|
222
228
|
}
|
223
229
|
|
224
|
-
reject(
|
230
|
+
reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
|
225
231
|
|
226
232
|
// Clean up request
|
227
233
|
request = null;
|
@@ -231,7 +237,7 @@ module.exports = function xhrAdapter(config) {
|
|
231
237
|
request.onerror = function handleError() {
|
232
238
|
// Real errors are hidden from us by the browser
|
233
239
|
// onerror should only fire if it's a network error
|
234
|
-
reject(
|
240
|
+
reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request, request));
|
235
241
|
|
236
242
|
// Clean up request
|
237
243
|
request = null;
|
@@ -244,10 +250,10 @@ module.exports = function xhrAdapter(config) {
|
|
244
250
|
if (config.timeoutErrorMessage) {
|
245
251
|
timeoutErrorMessage = config.timeoutErrorMessage;
|
246
252
|
}
|
247
|
-
reject(
|
253
|
+
reject(new AxiosError(
|
248
254
|
timeoutErrorMessage,
|
255
|
+
transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
|
249
256
|
config,
|
250
|
-
transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
|
251
257
|
request));
|
252
258
|
|
253
259
|
// Clean up request
|
@@ -308,7 +314,7 @@ module.exports = function xhrAdapter(config) {
|
|
308
314
|
if (!request) {
|
309
315
|
return;
|
310
316
|
}
|
311
|
-
reject(!cancel || (cancel && cancel.type) ? new
|
317
|
+
reject(!cancel || (cancel && cancel.type) ? new CanceledError() : cancel);
|
312
318
|
request.abort();
|
313
319
|
request = null;
|
314
320
|
};
|
@@ -323,6 +329,16 @@ module.exports = function xhrAdapter(config) {
|
|
323
329
|
requestData = null;
|
324
330
|
}
|
325
331
|
|
332
|
+
if (parsed.path === null) {
|
333
|
+
reject(new AxiosError('Malformed URL ' + fullPath, AxiosError.ERR_BAD_REQUEST, config));
|
334
|
+
return;
|
335
|
+
}
|
336
|
+
|
337
|
+
if (!utils.supportedProtocols.includes(protocol)) {
|
338
|
+
reject(new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_BAD_REQUEST, config));
|
339
|
+
return;
|
340
|
+
}
|
341
|
+
|
326
342
|
// Send the request
|
327
343
|
request.send(requestData);
|
328
344
|
});
|
@@ -378,11 +394,17 @@ var axios = createInstance(defaults);
|
|
378
394
|
axios.Axios = Axios;
|
379
395
|
|
380
396
|
// Expose Cancel & CancelToken
|
381
|
-
axios.
|
397
|
+
axios.CanceledError = __webpack_require__(/*! ./cancel/CanceledError */ "./lib/cancel/CanceledError.js");
|
382
398
|
axios.CancelToken = __webpack_require__(/*! ./cancel/CancelToken */ "./lib/cancel/CancelToken.js");
|
383
399
|
axios.isCancel = __webpack_require__(/*! ./cancel/isCancel */ "./lib/cancel/isCancel.js");
|
384
400
|
axios.VERSION = __webpack_require__(/*! ./env/data */ "./lib/env/data.js").version;
|
385
401
|
|
402
|
+
// Expose AxiosError class
|
403
|
+
axios.AxiosError = __webpack_require__(/*! ../lib/core/AxiosError */ "./lib/core/AxiosError.js");
|
404
|
+
|
405
|
+
// alias for CanceledError for backward compatibility
|
406
|
+
axios.Cancel = axios.CanceledError;
|
407
|
+
|
386
408
|
// Expose all/spread
|
387
409
|
axios.all = function all(promises) {
|
388
410
|
return Promise.all(promises);
|
@@ -398,37 +420,6 @@ module.exports = axios;
|
|
398
420
|
module.exports.default = axios;
|
399
421
|
|
400
422
|
|
401
|
-
/***/ }),
|
402
|
-
|
403
|
-
/***/ "./lib/cancel/Cancel.js":
|
404
|
-
/*!******************************!*\
|
405
|
-
!*** ./lib/cancel/Cancel.js ***!
|
406
|
-
\******************************/
|
407
|
-
/*! no static exports found */
|
408
|
-
/***/ (function(module, exports, __webpack_require__) {
|
409
|
-
|
410
|
-
"use strict";
|
411
|
-
|
412
|
-
|
413
|
-
/**
|
414
|
-
* A `Cancel` is an object that is thrown when an operation is canceled.
|
415
|
-
*
|
416
|
-
* @class
|
417
|
-
* @param {string=} message The message.
|
418
|
-
*/
|
419
|
-
function Cancel(message) {
|
420
|
-
this.message = message;
|
421
|
-
}
|
422
|
-
|
423
|
-
Cancel.prototype.toString = function toString() {
|
424
|
-
return 'Cancel' + (this.message ? ': ' + this.message : '');
|
425
|
-
};
|
426
|
-
|
427
|
-
Cancel.prototype.__CANCEL__ = true;
|
428
|
-
|
429
|
-
module.exports = Cancel;
|
430
|
-
|
431
|
-
|
432
423
|
/***/ }),
|
433
424
|
|
434
425
|
/***/ "./lib/cancel/CancelToken.js":
|
@@ -441,7 +432,7 @@ module.exports = Cancel;
|
|
441
432
|
"use strict";
|
442
433
|
|
443
434
|
|
444
|
-
var
|
435
|
+
var CanceledError = __webpack_require__(/*! ./CanceledError */ "./lib/cancel/CanceledError.js");
|
445
436
|
|
446
437
|
/**
|
447
438
|
* A `CancelToken` is an object that can be used to request cancellation of an operation.
|
@@ -497,13 +488,13 @@ function CancelToken(executor) {
|
|
497
488
|
return;
|
498
489
|
}
|
499
490
|
|
500
|
-
token.reason = new
|
491
|
+
token.reason = new CanceledError(message);
|
501
492
|
resolvePromise(token.reason);
|
502
493
|
});
|
503
494
|
}
|
504
495
|
|
505
496
|
/**
|
506
|
-
* Throws a `
|
497
|
+
* Throws a `CanceledError` if cancellation has been requested.
|
507
498
|
*/
|
508
499
|
CancelToken.prototype.throwIfRequested = function throwIfRequested() {
|
509
500
|
if (this.reason) {
|
@@ -560,6 +551,40 @@ CancelToken.source = function source() {
|
|
560
551
|
module.exports = CancelToken;
|
561
552
|
|
562
553
|
|
554
|
+
/***/ }),
|
555
|
+
|
556
|
+
/***/ "./lib/cancel/CanceledError.js":
|
557
|
+
/*!*************************************!*\
|
558
|
+
!*** ./lib/cancel/CanceledError.js ***!
|
559
|
+
\*************************************/
|
560
|
+
/*! no static exports found */
|
561
|
+
/***/ (function(module, exports, __webpack_require__) {
|
562
|
+
|
563
|
+
"use strict";
|
564
|
+
|
565
|
+
|
566
|
+
var AxiosError = __webpack_require__(/*! ../core/AxiosError */ "./lib/core/AxiosError.js");
|
567
|
+
var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
|
568
|
+
|
569
|
+
/**
|
570
|
+
* A `CanceledError` is an object that is thrown when an operation is canceled.
|
571
|
+
*
|
572
|
+
* @class
|
573
|
+
* @param {string=} message The message.
|
574
|
+
*/
|
575
|
+
function CanceledError(message) {
|
576
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
577
|
+
AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED);
|
578
|
+
this.name = 'CanceledError';
|
579
|
+
}
|
580
|
+
|
581
|
+
utils.inherits(CanceledError, AxiosError, {
|
582
|
+
__CANCEL__: true
|
583
|
+
});
|
584
|
+
|
585
|
+
module.exports = CanceledError;
|
586
|
+
|
587
|
+
|
563
588
|
/***/ }),
|
564
589
|
|
565
590
|
/***/ "./lib/cancel/isCancel.js":
|
@@ -594,6 +619,7 @@ var buildURL = __webpack_require__(/*! ../helpers/buildURL */ "./lib/helpers/bui
|
|
594
619
|
var InterceptorManager = __webpack_require__(/*! ./InterceptorManager */ "./lib/core/InterceptorManager.js");
|
595
620
|
var dispatchRequest = __webpack_require__(/*! ./dispatchRequest */ "./lib/core/dispatchRequest.js");
|
596
621
|
var mergeConfig = __webpack_require__(/*! ./mergeConfig */ "./lib/core/mergeConfig.js");
|
622
|
+
var buildFullPath = __webpack_require__(/*! ./buildFullPath */ "./lib/core/buildFullPath.js");
|
597
623
|
var validator = __webpack_require__(/*! ../helpers/validator */ "./lib/helpers/validator.js");
|
598
624
|
|
599
625
|
var validators = validator.validators;
|
@@ -708,7 +734,8 @@ Axios.prototype.request = function request(configOrUrl, config) {
|
|
708
734
|
|
709
735
|
Axios.prototype.getUri = function getUri(config) {
|
710
736
|
config = mergeConfig(this.defaults, config);
|
711
|
-
|
737
|
+
var fullPath = buildFullPath(config.baseURL, config.url);
|
738
|
+
return buildURL(fullPath, config.params, config.paramsSerializer);
|
712
739
|
};
|
713
740
|
|
714
741
|
// Provide aliases for supported request methods
|
@@ -737,6 +764,104 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
|
737
764
|
module.exports = Axios;
|
738
765
|
|
739
766
|
|
767
|
+
/***/ }),
|
768
|
+
|
769
|
+
/***/ "./lib/core/AxiosError.js":
|
770
|
+
/*!********************************!*\
|
771
|
+
!*** ./lib/core/AxiosError.js ***!
|
772
|
+
\********************************/
|
773
|
+
/*! no static exports found */
|
774
|
+
/***/ (function(module, exports, __webpack_require__) {
|
775
|
+
|
776
|
+
"use strict";
|
777
|
+
|
778
|
+
|
779
|
+
var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
|
780
|
+
|
781
|
+
/**
|
782
|
+
* Create an Error with the specified message, config, error code, request and response.
|
783
|
+
*
|
784
|
+
* @param {string} message The error message.
|
785
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
786
|
+
* @param {Object} [config] The config.
|
787
|
+
* @param {Object} [request] The request.
|
788
|
+
* @param {Object} [response] The response.
|
789
|
+
* @returns {Error} The created error.
|
790
|
+
*/
|
791
|
+
function AxiosError(message, code, config, request, response) {
|
792
|
+
Error.call(this);
|
793
|
+
this.message = message;
|
794
|
+
this.name = 'AxiosError';
|
795
|
+
code && (this.code = code);
|
796
|
+
config && (this.config = config);
|
797
|
+
request && (this.request = request);
|
798
|
+
response && (this.response = response);
|
799
|
+
}
|
800
|
+
|
801
|
+
utils.inherits(AxiosError, Error, {
|
802
|
+
toJSON: function toJSON() {
|
803
|
+
return {
|
804
|
+
// Standard
|
805
|
+
message: this.message,
|
806
|
+
name: this.name,
|
807
|
+
// Microsoft
|
808
|
+
description: this.description,
|
809
|
+
number: this.number,
|
810
|
+
// Mozilla
|
811
|
+
fileName: this.fileName,
|
812
|
+
lineNumber: this.lineNumber,
|
813
|
+
columnNumber: this.columnNumber,
|
814
|
+
stack: this.stack,
|
815
|
+
// Axios
|
816
|
+
config: this.config,
|
817
|
+
code: this.code,
|
818
|
+
status: this.response && this.response.status ? this.response.status : null
|
819
|
+
};
|
820
|
+
}
|
821
|
+
});
|
822
|
+
|
823
|
+
var prototype = AxiosError.prototype;
|
824
|
+
var descriptors = {};
|
825
|
+
|
826
|
+
[
|
827
|
+
'ERR_BAD_OPTION_VALUE',
|
828
|
+
'ERR_BAD_OPTION',
|
829
|
+
'ECONNABORTED',
|
830
|
+
'ETIMEDOUT',
|
831
|
+
'ERR_NETWORK',
|
832
|
+
'ERR_FR_TOO_MANY_REDIRECTS',
|
833
|
+
'ERR_DEPRECATED',
|
834
|
+
'ERR_BAD_RESPONSE',
|
835
|
+
'ERR_BAD_REQUEST',
|
836
|
+
'ERR_CANCELED'
|
837
|
+
// eslint-disable-next-line func-names
|
838
|
+
].forEach(function(code) {
|
839
|
+
descriptors[code] = {value: code};
|
840
|
+
});
|
841
|
+
|
842
|
+
Object.defineProperties(AxiosError, descriptors);
|
843
|
+
Object.defineProperty(prototype, 'isAxiosError', {value: true});
|
844
|
+
|
845
|
+
// eslint-disable-next-line func-names
|
846
|
+
AxiosError.from = function(error, code, config, request, response, customProps) {
|
847
|
+
var axiosError = Object.create(prototype);
|
848
|
+
|
849
|
+
utils.toFlatObject(error, axiosError, function filter(obj) {
|
850
|
+
return obj !== Error.prototype;
|
851
|
+
});
|
852
|
+
|
853
|
+
AxiosError.call(axiosError, error.message, code, config, request, response);
|
854
|
+
|
855
|
+
axiosError.name = error.name;
|
856
|
+
|
857
|
+
customProps && Object.assign(axiosError, customProps);
|
858
|
+
|
859
|
+
return axiosError;
|
860
|
+
};
|
861
|
+
|
862
|
+
module.exports = AxiosError;
|
863
|
+
|
864
|
+
|
740
865
|
/***/ }),
|
741
866
|
|
742
867
|
/***/ "./lib/core/InterceptorManager.js":
|
@@ -835,36 +960,6 @@ module.exports = function buildFullPath(baseURL, requestedURL) {
|
|
835
960
|
};
|
836
961
|
|
837
962
|
|
838
|
-
/***/ }),
|
839
|
-
|
840
|
-
/***/ "./lib/core/createError.js":
|
841
|
-
/*!*********************************!*\
|
842
|
-
!*** ./lib/core/createError.js ***!
|
843
|
-
\*********************************/
|
844
|
-
/*! no static exports found */
|
845
|
-
/***/ (function(module, exports, __webpack_require__) {
|
846
|
-
|
847
|
-
"use strict";
|
848
|
-
|
849
|
-
|
850
|
-
var enhanceError = __webpack_require__(/*! ./enhanceError */ "./lib/core/enhanceError.js");
|
851
|
-
|
852
|
-
/**
|
853
|
-
* Create an Error with the specified message, config, error code, request and response.
|
854
|
-
*
|
855
|
-
* @param {string} message The error message.
|
856
|
-
* @param {Object} config The config.
|
857
|
-
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
858
|
-
* @param {Object} [request] The request.
|
859
|
-
* @param {Object} [response] The response.
|
860
|
-
* @returns {Error} The created error.
|
861
|
-
*/
|
862
|
-
module.exports = function createError(message, config, code, request, response) {
|
863
|
-
var error = new Error(message);
|
864
|
-
return enhanceError(error, config, code, request, response);
|
865
|
-
};
|
866
|
-
|
867
|
-
|
868
963
|
/***/ }),
|
869
964
|
|
870
965
|
/***/ "./lib/core/dispatchRequest.js":
|
@@ -881,10 +976,10 @@ var utils = __webpack_require__(/*! ./../utils */ "./lib/utils.js");
|
|
881
976
|
var transformData = __webpack_require__(/*! ./transformData */ "./lib/core/transformData.js");
|
882
977
|
var isCancel = __webpack_require__(/*! ../cancel/isCancel */ "./lib/cancel/isCancel.js");
|
883
978
|
var defaults = __webpack_require__(/*! ../defaults */ "./lib/defaults/index.js");
|
884
|
-
var
|
979
|
+
var CanceledError = __webpack_require__(/*! ../cancel/CanceledError */ "./lib/cancel/CanceledError.js");
|
885
980
|
|
886
981
|
/**
|
887
|
-
* Throws a `
|
982
|
+
* Throws a `CanceledError` if cancellation has been requested.
|
888
983
|
*/
|
889
984
|
function throwIfCancellationRequested(config) {
|
890
985
|
if (config.cancelToken) {
|
@@ -892,7 +987,7 @@ function throwIfCancellationRequested(config) {
|
|
892
987
|
}
|
893
988
|
|
894
989
|
if (config.signal && config.signal.aborted) {
|
895
|
-
throw new
|
990
|
+
throw new CanceledError();
|
896
991
|
}
|
897
992
|
}
|
898
993
|
|
@@ -964,61 +1059,6 @@ module.exports = function dispatchRequest(config) {
|
|
964
1059
|
};
|
965
1060
|
|
966
1061
|
|
967
|
-
/***/ }),
|
968
|
-
|
969
|
-
/***/ "./lib/core/enhanceError.js":
|
970
|
-
/*!**********************************!*\
|
971
|
-
!*** ./lib/core/enhanceError.js ***!
|
972
|
-
\**********************************/
|
973
|
-
/*! no static exports found */
|
974
|
-
/***/ (function(module, exports, __webpack_require__) {
|
975
|
-
|
976
|
-
"use strict";
|
977
|
-
|
978
|
-
|
979
|
-
/**
|
980
|
-
* Update an Error with the specified config, error code, and response.
|
981
|
-
*
|
982
|
-
* @param {Error} error The error to update.
|
983
|
-
* @param {Object} config The config.
|
984
|
-
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
985
|
-
* @param {Object} [request] The request.
|
986
|
-
* @param {Object} [response] The response.
|
987
|
-
* @returns {Error} The error.
|
988
|
-
*/
|
989
|
-
module.exports = function enhanceError(error, config, code, request, response) {
|
990
|
-
error.config = config;
|
991
|
-
if (code) {
|
992
|
-
error.code = code;
|
993
|
-
}
|
994
|
-
|
995
|
-
error.request = request;
|
996
|
-
error.response = response;
|
997
|
-
error.isAxiosError = true;
|
998
|
-
|
999
|
-
error.toJSON = function toJSON() {
|
1000
|
-
return {
|
1001
|
-
// Standard
|
1002
|
-
message: this.message,
|
1003
|
-
name: this.name,
|
1004
|
-
// Microsoft
|
1005
|
-
description: this.description,
|
1006
|
-
number: this.number,
|
1007
|
-
// Mozilla
|
1008
|
-
fileName: this.fileName,
|
1009
|
-
lineNumber: this.lineNumber,
|
1010
|
-
columnNumber: this.columnNumber,
|
1011
|
-
stack: this.stack,
|
1012
|
-
// Axios
|
1013
|
-
config: this.config,
|
1014
|
-
code: this.code,
|
1015
|
-
status: this.response && this.response.status ? this.response.status : null
|
1016
|
-
};
|
1017
|
-
};
|
1018
|
-
return error;
|
1019
|
-
};
|
1020
|
-
|
1021
|
-
|
1022
1062
|
/***/ }),
|
1023
1063
|
|
1024
1064
|
/***/ "./lib/core/mergeConfig.js":
|
@@ -1111,6 +1151,7 @@ module.exports = function mergeConfig(config1, config2) {
|
|
1111
1151
|
'decompress': defaultToConfig2,
|
1112
1152
|
'maxContentLength': defaultToConfig2,
|
1113
1153
|
'maxBodyLength': defaultToConfig2,
|
1154
|
+
'beforeRedirect': defaultToConfig2,
|
1114
1155
|
'transport': defaultToConfig2,
|
1115
1156
|
'httpAgent': defaultToConfig2,
|
1116
1157
|
'httpsAgent': defaultToConfig2,
|
@@ -1142,7 +1183,7 @@ module.exports = function mergeConfig(config1, config2) {
|
|
1142
1183
|
"use strict";
|
1143
1184
|
|
1144
1185
|
|
1145
|
-
var
|
1186
|
+
var AxiosError = __webpack_require__(/*! ./AxiosError */ "./lib/core/AxiosError.js");
|
1146
1187
|
|
1147
1188
|
/**
|
1148
1189
|
* Resolve or reject a Promise based on response status.
|
@@ -1156,10 +1197,10 @@ module.exports = function settle(resolve, reject, response) {
|
|
1156
1197
|
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
1157
1198
|
resolve(response);
|
1158
1199
|
} else {
|
1159
|
-
reject(
|
1200
|
+
reject(new AxiosError(
|
1160
1201
|
'Request failed with status code ' + response.status,
|
1202
|
+
[AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
1161
1203
|
response.config,
|
1162
|
-
null,
|
1163
1204
|
response.request,
|
1164
1205
|
response
|
1165
1206
|
));
|
@@ -1215,7 +1256,7 @@ module.exports = function transformData(data, headers, fns) {
|
|
1215
1256
|
|
1216
1257
|
var utils = __webpack_require__(/*! ../utils */ "./lib/utils.js");
|
1217
1258
|
var normalizeHeaderName = __webpack_require__(/*! ../helpers/normalizeHeaderName */ "./lib/helpers/normalizeHeaderName.js");
|
1218
|
-
var
|
1259
|
+
var AxiosError = __webpack_require__(/*! ../core/AxiosError */ "./lib/core/AxiosError.js");
|
1219
1260
|
var transitionalDefaults = __webpack_require__(/*! ./transitional */ "./lib/defaults/transitional.js");
|
1220
1261
|
|
1221
1262
|
var DEFAULT_CONTENT_TYPE = {
|
@@ -1300,7 +1341,7 @@ var defaults = {
|
|
1300
1341
|
} catch (e) {
|
1301
1342
|
if (strictJSONParsing) {
|
1302
1343
|
if (e.name === 'SyntaxError') {
|
1303
|
-
throw
|
1344
|
+
throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
|
1304
1345
|
}
|
1305
1346
|
throw e;
|
1306
1347
|
}
|
@@ -1844,6 +1885,7 @@ module.exports = function spread(callback) {
|
|
1844
1885
|
|
1845
1886
|
|
1846
1887
|
var VERSION = __webpack_require__(/*! ../env/data */ "./lib/env/data.js").version;
|
1888
|
+
var AxiosError = __webpack_require__(/*! ../core/AxiosError */ "./lib/core/AxiosError.js");
|
1847
1889
|
|
1848
1890
|
var validators = {};
|
1849
1891
|
|
@@ -1871,7 +1913,10 @@ validators.transitional = function transitional(validator, version, message) {
|
|
1871
1913
|
// eslint-disable-next-line func-names
|
1872
1914
|
return function(value, opt, opts) {
|
1873
1915
|
if (validator === false) {
|
1874
|
-
throw new
|
1916
|
+
throw new AxiosError(
|
1917
|
+
formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
|
1918
|
+
AxiosError.ERR_DEPRECATED
|
1919
|
+
);
|
1875
1920
|
}
|
1876
1921
|
|
1877
1922
|
if (version && !deprecatedWarnings[opt]) {
|
@@ -1898,7 +1943,7 @@ validators.transitional = function transitional(validator, version, message) {
|
|
1898
1943
|
|
1899
1944
|
function assertOptions(options, schema, allowUnknown) {
|
1900
1945
|
if (typeof options !== 'object') {
|
1901
|
-
throw new
|
1946
|
+
throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
|
1902
1947
|
}
|
1903
1948
|
var keys = Object.keys(options);
|
1904
1949
|
var i = keys.length;
|
@@ -1909,12 +1954,12 @@ function assertOptions(options, schema, allowUnknown) {
|
|
1909
1954
|
var value = options[opt];
|
1910
1955
|
var result = value === undefined || validator(value, opt, options);
|
1911
1956
|
if (result !== true) {
|
1912
|
-
throw new
|
1957
|
+
throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
|
1913
1958
|
}
|
1914
1959
|
continue;
|
1915
1960
|
}
|
1916
1961
|
if (allowUnknown !== true) {
|
1917
|
-
throw
|
1962
|
+
throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
|
1918
1963
|
}
|
1919
1964
|
}
|
1920
1965
|
}
|
@@ -1943,6 +1988,22 @@ var bind = __webpack_require__(/*! ./helpers/bind */ "./lib/helpers/bind.js");
|
|
1943
1988
|
|
1944
1989
|
var toString = Object.prototype.toString;
|
1945
1990
|
|
1991
|
+
/**
|
1992
|
+
* Array with axios supported protocols.
|
1993
|
+
*/
|
1994
|
+
var supportedProtocols = [ 'http:', 'https:', 'file:' ];
|
1995
|
+
|
1996
|
+
/**
|
1997
|
+
* Returns URL protocol passed as param if is not undefined or null,
|
1998
|
+
* otherwise just returns 'http:'
|
1999
|
+
*
|
2000
|
+
* @param {String} protocol The String value of URL protocol
|
2001
|
+
* @returns {String} Protocol if the value is not undefined or null
|
2002
|
+
*/
|
2003
|
+
function getProtocol(protocol) {
|
2004
|
+
return protocol || 'http:';
|
2005
|
+
}
|
2006
|
+
|
1946
2007
|
/**
|
1947
2008
|
* Determine if a value is an Array
|
1948
2009
|
*
|
@@ -2260,7 +2321,55 @@ function stripBOM(content) {
|
|
2260
2321
|
return content;
|
2261
2322
|
}
|
2262
2323
|
|
2324
|
+
/**
|
2325
|
+
* Inherit the prototype methods from one constructor into another
|
2326
|
+
* @param {function} constructor
|
2327
|
+
* @param {function} superConstructor
|
2328
|
+
* @param {object} [props]
|
2329
|
+
* @param {object} [descriptors]
|
2330
|
+
*/
|
2331
|
+
|
2332
|
+
function inherits(constructor, superConstructor, props, descriptors) {
|
2333
|
+
constructor.prototype = Object.create(superConstructor.prototype, descriptors);
|
2334
|
+
constructor.prototype.constructor = constructor;
|
2335
|
+
props && Object.assign(constructor.prototype, props);
|
2336
|
+
}
|
2337
|
+
|
2338
|
+
/**
|
2339
|
+
* Resolve object with deep prototype chain to a flat object
|
2340
|
+
* @param {Object} sourceObj source object
|
2341
|
+
* @param {Object} [destObj]
|
2342
|
+
* @param {Function} [filter]
|
2343
|
+
* @returns {Object}
|
2344
|
+
*/
|
2345
|
+
|
2346
|
+
function toFlatObject(sourceObj, destObj, filter) {
|
2347
|
+
var props;
|
2348
|
+
var i;
|
2349
|
+
var prop;
|
2350
|
+
var merged = {};
|
2351
|
+
|
2352
|
+
destObj = destObj || {};
|
2353
|
+
|
2354
|
+
do {
|
2355
|
+
props = Object.getOwnPropertyNames(sourceObj);
|
2356
|
+
i = props.length;
|
2357
|
+
while (i-- > 0) {
|
2358
|
+
prop = props[i];
|
2359
|
+
if (!merged[prop]) {
|
2360
|
+
destObj[prop] = sourceObj[prop];
|
2361
|
+
merged[prop] = true;
|
2362
|
+
}
|
2363
|
+
}
|
2364
|
+
sourceObj = Object.getPrototypeOf(sourceObj);
|
2365
|
+
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
2366
|
+
|
2367
|
+
return destObj;
|
2368
|
+
}
|
2369
|
+
|
2263
2370
|
module.exports = {
|
2371
|
+
supportedProtocols: supportedProtocols,
|
2372
|
+
getProtocol: getProtocol,
|
2264
2373
|
isArray: isArray,
|
2265
2374
|
isArrayBuffer: isArrayBuffer,
|
2266
2375
|
isBuffer: isBuffer,
|
@@ -2282,7 +2391,1585 @@ module.exports = {
|
|
2282
2391
|
merge: merge,
|
2283
2392
|
extend: extend,
|
2284
2393
|
trim: trim,
|
2285
|
-
stripBOM: stripBOM
|
2394
|
+
stripBOM: stripBOM,
|
2395
|
+
inherits: inherits,
|
2396
|
+
toFlatObject: toFlatObject
|
2397
|
+
};
|
2398
|
+
|
2399
|
+
|
2400
|
+
/***/ }),
|
2401
|
+
|
2402
|
+
/***/ "./node_modules/node-libs-browser/node_modules/punycode/punycode.js":
|
2403
|
+
/*!**************************************************************************!*\
|
2404
|
+
!*** ./node_modules/node-libs-browser/node_modules/punycode/punycode.js ***!
|
2405
|
+
\**************************************************************************/
|
2406
|
+
/*! no static exports found */
|
2407
|
+
/***/ (function(module, exports, __webpack_require__) {
|
2408
|
+
|
2409
|
+
/* WEBPACK VAR INJECTION */(function(module, global) {var __WEBPACK_AMD_DEFINE_RESULT__;/*! https://mths.be/punycode v1.4.1 by @mathias */
|
2410
|
+
;(function(root) {
|
2411
|
+
|
2412
|
+
/** Detect free variables */
|
2413
|
+
var freeExports = true && exports &&
|
2414
|
+
!exports.nodeType && exports;
|
2415
|
+
var freeModule = true && module &&
|
2416
|
+
!module.nodeType && module;
|
2417
|
+
var freeGlobal = typeof global == 'object' && global;
|
2418
|
+
if (
|
2419
|
+
freeGlobal.global === freeGlobal ||
|
2420
|
+
freeGlobal.window === freeGlobal ||
|
2421
|
+
freeGlobal.self === freeGlobal
|
2422
|
+
) {
|
2423
|
+
root = freeGlobal;
|
2424
|
+
}
|
2425
|
+
|
2426
|
+
/**
|
2427
|
+
* The `punycode` object.
|
2428
|
+
* @name punycode
|
2429
|
+
* @type Object
|
2430
|
+
*/
|
2431
|
+
var punycode,
|
2432
|
+
|
2433
|
+
/** Highest positive signed 32-bit float value */
|
2434
|
+
maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1
|
2435
|
+
|
2436
|
+
/** Bootstring parameters */
|
2437
|
+
base = 36,
|
2438
|
+
tMin = 1,
|
2439
|
+
tMax = 26,
|
2440
|
+
skew = 38,
|
2441
|
+
damp = 700,
|
2442
|
+
initialBias = 72,
|
2443
|
+
initialN = 128, // 0x80
|
2444
|
+
delimiter = '-', // '\x2D'
|
2445
|
+
|
2446
|
+
/** Regular expressions */
|
2447
|
+
regexPunycode = /^xn--/,
|
2448
|
+
regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars
|
2449
|
+
regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators
|
2450
|
+
|
2451
|
+
/** Error messages */
|
2452
|
+
errors = {
|
2453
|
+
'overflow': 'Overflow: input needs wider integers to process',
|
2454
|
+
'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
|
2455
|
+
'invalid-input': 'Invalid input'
|
2456
|
+
},
|
2457
|
+
|
2458
|
+
/** Convenience shortcuts */
|
2459
|
+
baseMinusTMin = base - tMin,
|
2460
|
+
floor = Math.floor,
|
2461
|
+
stringFromCharCode = String.fromCharCode,
|
2462
|
+
|
2463
|
+
/** Temporary variable */
|
2464
|
+
key;
|
2465
|
+
|
2466
|
+
/*--------------------------------------------------------------------------*/
|
2467
|
+
|
2468
|
+
/**
|
2469
|
+
* A generic error utility function.
|
2470
|
+
* @private
|
2471
|
+
* @param {String} type The error type.
|
2472
|
+
* @returns {Error} Throws a `RangeError` with the applicable error message.
|
2473
|
+
*/
|
2474
|
+
function error(type) {
|
2475
|
+
throw new RangeError(errors[type]);
|
2476
|
+
}
|
2477
|
+
|
2478
|
+
/**
|
2479
|
+
* A generic `Array#map` utility function.
|
2480
|
+
* @private
|
2481
|
+
* @param {Array} array The array to iterate over.
|
2482
|
+
* @param {Function} callback The function that gets called for every array
|
2483
|
+
* item.
|
2484
|
+
* @returns {Array} A new array of values returned by the callback function.
|
2485
|
+
*/
|
2486
|
+
function map(array, fn) {
|
2487
|
+
var length = array.length;
|
2488
|
+
var result = [];
|
2489
|
+
while (length--) {
|
2490
|
+
result[length] = fn(array[length]);
|
2491
|
+
}
|
2492
|
+
return result;
|
2493
|
+
}
|
2494
|
+
|
2495
|
+
/**
|
2496
|
+
* A simple `Array#map`-like wrapper to work with domain name strings or email
|
2497
|
+
* addresses.
|
2498
|
+
* @private
|
2499
|
+
* @param {String} domain The domain name or email address.
|
2500
|
+
* @param {Function} callback The function that gets called for every
|
2501
|
+
* character.
|
2502
|
+
* @returns {Array} A new string of characters returned by the callback
|
2503
|
+
* function.
|
2504
|
+
*/
|
2505
|
+
function mapDomain(string, fn) {
|
2506
|
+
var parts = string.split('@');
|
2507
|
+
var result = '';
|
2508
|
+
if (parts.length > 1) {
|
2509
|
+
// In email addresses, only the domain name should be punycoded. Leave
|
2510
|
+
// the local part (i.e. everything up to `@`) intact.
|
2511
|
+
result = parts[0] + '@';
|
2512
|
+
string = parts[1];
|
2513
|
+
}
|
2514
|
+
// Avoid `split(regex)` for IE8 compatibility. See #17.
|
2515
|
+
string = string.replace(regexSeparators, '\x2E');
|
2516
|
+
var labels = string.split('.');
|
2517
|
+
var encoded = map(labels, fn).join('.');
|
2518
|
+
return result + encoded;
|
2519
|
+
}
|
2520
|
+
|
2521
|
+
/**
|
2522
|
+
* Creates an array containing the numeric code points of each Unicode
|
2523
|
+
* character in the string. While JavaScript uses UCS-2 internally,
|
2524
|
+
* this function will convert a pair of surrogate halves (each of which
|
2525
|
+
* UCS-2 exposes as separate characters) into a single code point,
|
2526
|
+
* matching UTF-16.
|
2527
|
+
* @see `punycode.ucs2.encode`
|
2528
|
+
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
2529
|
+
* @memberOf punycode.ucs2
|
2530
|
+
* @name decode
|
2531
|
+
* @param {String} string The Unicode input string (UCS-2).
|
2532
|
+
* @returns {Array} The new array of code points.
|
2533
|
+
*/
|
2534
|
+
function ucs2decode(string) {
|
2535
|
+
var output = [],
|
2536
|
+
counter = 0,
|
2537
|
+
length = string.length,
|
2538
|
+
value,
|
2539
|
+
extra;
|
2540
|
+
while (counter < length) {
|
2541
|
+
value = string.charCodeAt(counter++);
|
2542
|
+
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
|
2543
|
+
// high surrogate, and there is a next character
|
2544
|
+
extra = string.charCodeAt(counter++);
|
2545
|
+
if ((extra & 0xFC00) == 0xDC00) { // low surrogate
|
2546
|
+
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
2547
|
+
} else {
|
2548
|
+
// unmatched surrogate; only append this code unit, in case the next
|
2549
|
+
// code unit is the high surrogate of a surrogate pair
|
2550
|
+
output.push(value);
|
2551
|
+
counter--;
|
2552
|
+
}
|
2553
|
+
} else {
|
2554
|
+
output.push(value);
|
2555
|
+
}
|
2556
|
+
}
|
2557
|
+
return output;
|
2558
|
+
}
|
2559
|
+
|
2560
|
+
/**
|
2561
|
+
* Creates a string based on an array of numeric code points.
|
2562
|
+
* @see `punycode.ucs2.decode`
|
2563
|
+
* @memberOf punycode.ucs2
|
2564
|
+
* @name encode
|
2565
|
+
* @param {Array} codePoints The array of numeric code points.
|
2566
|
+
* @returns {String} The new Unicode string (UCS-2).
|
2567
|
+
*/
|
2568
|
+
function ucs2encode(array) {
|
2569
|
+
return map(array, function(value) {
|
2570
|
+
var output = '';
|
2571
|
+
if (value > 0xFFFF) {
|
2572
|
+
value -= 0x10000;
|
2573
|
+
output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
|
2574
|
+
value = 0xDC00 | value & 0x3FF;
|
2575
|
+
}
|
2576
|
+
output += stringFromCharCode(value);
|
2577
|
+
return output;
|
2578
|
+
}).join('');
|
2579
|
+
}
|
2580
|
+
|
2581
|
+
/**
|
2582
|
+
* Converts a basic code point into a digit/integer.
|
2583
|
+
* @see `digitToBasic()`
|
2584
|
+
* @private
|
2585
|
+
* @param {Number} codePoint The basic numeric code point value.
|
2586
|
+
* @returns {Number} The numeric value of a basic code point (for use in
|
2587
|
+
* representing integers) in the range `0` to `base - 1`, or `base` if
|
2588
|
+
* the code point does not represent a value.
|
2589
|
+
*/
|
2590
|
+
function basicToDigit(codePoint) {
|
2591
|
+
if (codePoint - 48 < 10) {
|
2592
|
+
return codePoint - 22;
|
2593
|
+
}
|
2594
|
+
if (codePoint - 65 < 26) {
|
2595
|
+
return codePoint - 65;
|
2596
|
+
}
|
2597
|
+
if (codePoint - 97 < 26) {
|
2598
|
+
return codePoint - 97;
|
2599
|
+
}
|
2600
|
+
return base;
|
2601
|
+
}
|
2602
|
+
|
2603
|
+
/**
|
2604
|
+
* Converts a digit/integer into a basic code point.
|
2605
|
+
* @see `basicToDigit()`
|
2606
|
+
* @private
|
2607
|
+
* @param {Number} digit The numeric value of a basic code point.
|
2608
|
+
* @returns {Number} The basic code point whose value (when used for
|
2609
|
+
* representing integers) is `digit`, which needs to be in the range
|
2610
|
+
* `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
|
2611
|
+
* used; else, the lowercase form is used. The behavior is undefined
|
2612
|
+
* if `flag` is non-zero and `digit` has no uppercase form.
|
2613
|
+
*/
|
2614
|
+
function digitToBasic(digit, flag) {
|
2615
|
+
// 0..25 map to ASCII a..z or A..Z
|
2616
|
+
// 26..35 map to ASCII 0..9
|
2617
|
+
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
2618
|
+
}
|
2619
|
+
|
2620
|
+
/**
|
2621
|
+
* Bias adaptation function as per section 3.4 of RFC 3492.
|
2622
|
+
* https://tools.ietf.org/html/rfc3492#section-3.4
|
2623
|
+
* @private
|
2624
|
+
*/
|
2625
|
+
function adapt(delta, numPoints, firstTime) {
|
2626
|
+
var k = 0;
|
2627
|
+
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
2628
|
+
delta += floor(delta / numPoints);
|
2629
|
+
for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) {
|
2630
|
+
delta = floor(delta / baseMinusTMin);
|
2631
|
+
}
|
2632
|
+
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
2633
|
+
}
|
2634
|
+
|
2635
|
+
/**
|
2636
|
+
* Converts a Punycode string of ASCII-only symbols to a string of Unicode
|
2637
|
+
* symbols.
|
2638
|
+
* @memberOf punycode
|
2639
|
+
* @param {String} input The Punycode string of ASCII-only symbols.
|
2640
|
+
* @returns {String} The resulting string of Unicode symbols.
|
2641
|
+
*/
|
2642
|
+
function decode(input) {
|
2643
|
+
// Don't use UCS-2
|
2644
|
+
var output = [],
|
2645
|
+
inputLength = input.length,
|
2646
|
+
out,
|
2647
|
+
i = 0,
|
2648
|
+
n = initialN,
|
2649
|
+
bias = initialBias,
|
2650
|
+
basic,
|
2651
|
+
j,
|
2652
|
+
index,
|
2653
|
+
oldi,
|
2654
|
+
w,
|
2655
|
+
k,
|
2656
|
+
digit,
|
2657
|
+
t,
|
2658
|
+
/** Cached calculation results */
|
2659
|
+
baseMinusT;
|
2660
|
+
|
2661
|
+
// Handle the basic code points: let `basic` be the number of input code
|
2662
|
+
// points before the last delimiter, or `0` if there is none, then copy
|
2663
|
+
// the first basic code points to the output.
|
2664
|
+
|
2665
|
+
basic = input.lastIndexOf(delimiter);
|
2666
|
+
if (basic < 0) {
|
2667
|
+
basic = 0;
|
2668
|
+
}
|
2669
|
+
|
2670
|
+
for (j = 0; j < basic; ++j) {
|
2671
|
+
// if it's not a basic code point
|
2672
|
+
if (input.charCodeAt(j) >= 0x80) {
|
2673
|
+
error('not-basic');
|
2674
|
+
}
|
2675
|
+
output.push(input.charCodeAt(j));
|
2676
|
+
}
|
2677
|
+
|
2678
|
+
// Main decoding loop: start just after the last delimiter if any basic code
|
2679
|
+
// points were copied; start at the beginning otherwise.
|
2680
|
+
|
2681
|
+
for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) {
|
2682
|
+
|
2683
|
+
// `index` is the index of the next character to be consumed.
|
2684
|
+
// Decode a generalized variable-length integer into `delta`,
|
2685
|
+
// which gets added to `i`. The overflow checking is easier
|
2686
|
+
// if we increase `i` as we go, then subtract off its starting
|
2687
|
+
// value at the end to obtain `delta`.
|
2688
|
+
for (oldi = i, w = 1, k = base; /* no condition */; k += base) {
|
2689
|
+
|
2690
|
+
if (index >= inputLength) {
|
2691
|
+
error('invalid-input');
|
2692
|
+
}
|
2693
|
+
|
2694
|
+
digit = basicToDigit(input.charCodeAt(index++));
|
2695
|
+
|
2696
|
+
if (digit >= base || digit > floor((maxInt - i) / w)) {
|
2697
|
+
error('overflow');
|
2698
|
+
}
|
2699
|
+
|
2700
|
+
i += digit * w;
|
2701
|
+
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
2702
|
+
|
2703
|
+
if (digit < t) {
|
2704
|
+
break;
|
2705
|
+
}
|
2706
|
+
|
2707
|
+
baseMinusT = base - t;
|
2708
|
+
if (w > floor(maxInt / baseMinusT)) {
|
2709
|
+
error('overflow');
|
2710
|
+
}
|
2711
|
+
|
2712
|
+
w *= baseMinusT;
|
2713
|
+
|
2714
|
+
}
|
2715
|
+
|
2716
|
+
out = output.length + 1;
|
2717
|
+
bias = adapt(i - oldi, out, oldi == 0);
|
2718
|
+
|
2719
|
+
// `i` was supposed to wrap around from `out` to `0`,
|
2720
|
+
// incrementing `n` each time, so we'll fix that now:
|
2721
|
+
if (floor(i / out) > maxInt - n) {
|
2722
|
+
error('overflow');
|
2723
|
+
}
|
2724
|
+
|
2725
|
+
n += floor(i / out);
|
2726
|
+
i %= out;
|
2727
|
+
|
2728
|
+
// Insert `n` at position `i` of the output
|
2729
|
+
output.splice(i++, 0, n);
|
2730
|
+
|
2731
|
+
}
|
2732
|
+
|
2733
|
+
return ucs2encode(output);
|
2734
|
+
}
|
2735
|
+
|
2736
|
+
/**
|
2737
|
+
* Converts a string of Unicode symbols (e.g. a domain name label) to a
|
2738
|
+
* Punycode string of ASCII-only symbols.
|
2739
|
+
* @memberOf punycode
|
2740
|
+
* @param {String} input The string of Unicode symbols.
|
2741
|
+
* @returns {String} The resulting Punycode string of ASCII-only symbols.
|
2742
|
+
*/
|
2743
|
+
function encode(input) {
|
2744
|
+
var n,
|
2745
|
+
delta,
|
2746
|
+
handledCPCount,
|
2747
|
+
basicLength,
|
2748
|
+
bias,
|
2749
|
+
j,
|
2750
|
+
m,
|
2751
|
+
q,
|
2752
|
+
k,
|
2753
|
+
t,
|
2754
|
+
currentValue,
|
2755
|
+
output = [],
|
2756
|
+
/** `inputLength` will hold the number of code points in `input`. */
|
2757
|
+
inputLength,
|
2758
|
+
/** Cached calculation results */
|
2759
|
+
handledCPCountPlusOne,
|
2760
|
+
baseMinusT,
|
2761
|
+
qMinusT;
|
2762
|
+
|
2763
|
+
// Convert the input in UCS-2 to Unicode
|
2764
|
+
input = ucs2decode(input);
|
2765
|
+
|
2766
|
+
// Cache the length
|
2767
|
+
inputLength = input.length;
|
2768
|
+
|
2769
|
+
// Initialize the state
|
2770
|
+
n = initialN;
|
2771
|
+
delta = 0;
|
2772
|
+
bias = initialBias;
|
2773
|
+
|
2774
|
+
// Handle the basic code points
|
2775
|
+
for (j = 0; j < inputLength; ++j) {
|
2776
|
+
currentValue = input[j];
|
2777
|
+
if (currentValue < 0x80) {
|
2778
|
+
output.push(stringFromCharCode(currentValue));
|
2779
|
+
}
|
2780
|
+
}
|
2781
|
+
|
2782
|
+
handledCPCount = basicLength = output.length;
|
2783
|
+
|
2784
|
+
// `handledCPCount` is the number of code points that have been handled;
|
2785
|
+
// `basicLength` is the number of basic code points.
|
2786
|
+
|
2787
|
+
// Finish the basic string - if it is not empty - with a delimiter
|
2788
|
+
if (basicLength) {
|
2789
|
+
output.push(delimiter);
|
2790
|
+
}
|
2791
|
+
|
2792
|
+
// Main encoding loop:
|
2793
|
+
while (handledCPCount < inputLength) {
|
2794
|
+
|
2795
|
+
// All non-basic code points < n have been handled already. Find the next
|
2796
|
+
// larger one:
|
2797
|
+
for (m = maxInt, j = 0; j < inputLength; ++j) {
|
2798
|
+
currentValue = input[j];
|
2799
|
+
if (currentValue >= n && currentValue < m) {
|
2800
|
+
m = currentValue;
|
2801
|
+
}
|
2802
|
+
}
|
2803
|
+
|
2804
|
+
// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
|
2805
|
+
// but guard against overflow
|
2806
|
+
handledCPCountPlusOne = handledCPCount + 1;
|
2807
|
+
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
|
2808
|
+
error('overflow');
|
2809
|
+
}
|
2810
|
+
|
2811
|
+
delta += (m - n) * handledCPCountPlusOne;
|
2812
|
+
n = m;
|
2813
|
+
|
2814
|
+
for (j = 0; j < inputLength; ++j) {
|
2815
|
+
currentValue = input[j];
|
2816
|
+
|
2817
|
+
if (currentValue < n && ++delta > maxInt) {
|
2818
|
+
error('overflow');
|
2819
|
+
}
|
2820
|
+
|
2821
|
+
if (currentValue == n) {
|
2822
|
+
// Represent delta as a generalized variable-length integer
|
2823
|
+
for (q = delta, k = base; /* no condition */; k += base) {
|
2824
|
+
t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
|
2825
|
+
if (q < t) {
|
2826
|
+
break;
|
2827
|
+
}
|
2828
|
+
qMinusT = q - t;
|
2829
|
+
baseMinusT = base - t;
|
2830
|
+
output.push(
|
2831
|
+
stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
|
2832
|
+
);
|
2833
|
+
q = floor(qMinusT / baseMinusT);
|
2834
|
+
}
|
2835
|
+
|
2836
|
+
output.push(stringFromCharCode(digitToBasic(q, 0)));
|
2837
|
+
bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
|
2838
|
+
delta = 0;
|
2839
|
+
++handledCPCount;
|
2840
|
+
}
|
2841
|
+
}
|
2842
|
+
|
2843
|
+
++delta;
|
2844
|
+
++n;
|
2845
|
+
|
2846
|
+
}
|
2847
|
+
return output.join('');
|
2848
|
+
}
|
2849
|
+
|
2850
|
+
/**
|
2851
|
+
* Converts a Punycode string representing a domain name or an email address
|
2852
|
+
* to Unicode. Only the Punycoded parts of the input will be converted, i.e.
|
2853
|
+
* it doesn't matter if you call it on a string that has already been
|
2854
|
+
* converted to Unicode.
|
2855
|
+
* @memberOf punycode
|
2856
|
+
* @param {String} input The Punycoded domain name or email address to
|
2857
|
+
* convert to Unicode.
|
2858
|
+
* @returns {String} The Unicode representation of the given Punycode
|
2859
|
+
* string.
|
2860
|
+
*/
|
2861
|
+
function toUnicode(input) {
|
2862
|
+
return mapDomain(input, function(string) {
|
2863
|
+
return regexPunycode.test(string)
|
2864
|
+
? decode(string.slice(4).toLowerCase())
|
2865
|
+
: string;
|
2866
|
+
});
|
2867
|
+
}
|
2868
|
+
|
2869
|
+
/**
|
2870
|
+
* Converts a Unicode string representing a domain name or an email address to
|
2871
|
+
* Punycode. Only the non-ASCII parts of the domain name will be converted,
|
2872
|
+
* i.e. it doesn't matter if you call it with a domain that's already in
|
2873
|
+
* ASCII.
|
2874
|
+
* @memberOf punycode
|
2875
|
+
* @param {String} input The domain name or email address to convert, as a
|
2876
|
+
* Unicode string.
|
2877
|
+
* @returns {String} The Punycode representation of the given domain name or
|
2878
|
+
* email address.
|
2879
|
+
*/
|
2880
|
+
function toASCII(input) {
|
2881
|
+
return mapDomain(input, function(string) {
|
2882
|
+
return regexNonASCII.test(string)
|
2883
|
+
? 'xn--' + encode(string)
|
2884
|
+
: string;
|
2885
|
+
});
|
2886
|
+
}
|
2887
|
+
|
2888
|
+
/*--------------------------------------------------------------------------*/
|
2889
|
+
|
2890
|
+
/** Define the public API */
|
2891
|
+
punycode = {
|
2892
|
+
/**
|
2893
|
+
* A string representing the current Punycode.js version number.
|
2894
|
+
* @memberOf punycode
|
2895
|
+
* @type String
|
2896
|
+
*/
|
2897
|
+
'version': '1.4.1',
|
2898
|
+
/**
|
2899
|
+
* An object of methods to convert from JavaScript's internal character
|
2900
|
+
* representation (UCS-2) to Unicode code points, and back.
|
2901
|
+
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
2902
|
+
* @memberOf punycode
|
2903
|
+
* @type Object
|
2904
|
+
*/
|
2905
|
+
'ucs2': {
|
2906
|
+
'decode': ucs2decode,
|
2907
|
+
'encode': ucs2encode
|
2908
|
+
},
|
2909
|
+
'decode': decode,
|
2910
|
+
'encode': encode,
|
2911
|
+
'toASCII': toASCII,
|
2912
|
+
'toUnicode': toUnicode
|
2913
|
+
};
|
2914
|
+
|
2915
|
+
/** Expose `punycode` */
|
2916
|
+
// Some AMD build optimizers, like r.js, check for specific condition patterns
|
2917
|
+
// like the following:
|
2918
|
+
if (
|
2919
|
+
true
|
2920
|
+
) {
|
2921
|
+
!(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
|
2922
|
+
return punycode;
|
2923
|
+
}).call(exports, __webpack_require__, exports, module),
|
2924
|
+
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
2925
|
+
} else {}
|
2926
|
+
|
2927
|
+
}(this));
|
2928
|
+
|
2929
|
+
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/module.js */ "./node_modules/webpack/buildin/module.js")(module), __webpack_require__(/*! ./../../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
|
2930
|
+
|
2931
|
+
/***/ }),
|
2932
|
+
|
2933
|
+
/***/ "./node_modules/querystring-es3/decode.js":
|
2934
|
+
/*!************************************************!*\
|
2935
|
+
!*** ./node_modules/querystring-es3/decode.js ***!
|
2936
|
+
\************************************************/
|
2937
|
+
/*! no static exports found */
|
2938
|
+
/***/ (function(module, exports, __webpack_require__) {
|
2939
|
+
|
2940
|
+
"use strict";
|
2941
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
2942
|
+
//
|
2943
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
2944
|
+
// copy of this software and associated documentation files (the
|
2945
|
+
// "Software"), to deal in the Software without restriction, including
|
2946
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
2947
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
2948
|
+
// persons to whom the Software is furnished to do so, subject to the
|
2949
|
+
// following conditions:
|
2950
|
+
//
|
2951
|
+
// The above copyright notice and this permission notice shall be included
|
2952
|
+
// in all copies or substantial portions of the Software.
|
2953
|
+
//
|
2954
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
2955
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
2956
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
2957
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
2958
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
2959
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
2960
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2961
|
+
|
2962
|
+
|
2963
|
+
|
2964
|
+
// If obj.hasOwnProperty has been overridden, then calling
|
2965
|
+
// obj.hasOwnProperty(prop) will break.
|
2966
|
+
// See: https://github.com/joyent/node/issues/1707
|
2967
|
+
function hasOwnProperty(obj, prop) {
|
2968
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
2969
|
+
}
|
2970
|
+
|
2971
|
+
module.exports = function(qs, sep, eq, options) {
|
2972
|
+
sep = sep || '&';
|
2973
|
+
eq = eq || '=';
|
2974
|
+
var obj = {};
|
2975
|
+
|
2976
|
+
if (typeof qs !== 'string' || qs.length === 0) {
|
2977
|
+
return obj;
|
2978
|
+
}
|
2979
|
+
|
2980
|
+
var regexp = /\+/g;
|
2981
|
+
qs = qs.split(sep);
|
2982
|
+
|
2983
|
+
var maxKeys = 1000;
|
2984
|
+
if (options && typeof options.maxKeys === 'number') {
|
2985
|
+
maxKeys = options.maxKeys;
|
2986
|
+
}
|
2987
|
+
|
2988
|
+
var len = qs.length;
|
2989
|
+
// maxKeys <= 0 means that we should not limit keys count
|
2990
|
+
if (maxKeys > 0 && len > maxKeys) {
|
2991
|
+
len = maxKeys;
|
2992
|
+
}
|
2993
|
+
|
2994
|
+
for (var i = 0; i < len; ++i) {
|
2995
|
+
var x = qs[i].replace(regexp, '%20'),
|
2996
|
+
idx = x.indexOf(eq),
|
2997
|
+
kstr, vstr, k, v;
|
2998
|
+
|
2999
|
+
if (idx >= 0) {
|
3000
|
+
kstr = x.substr(0, idx);
|
3001
|
+
vstr = x.substr(idx + 1);
|
3002
|
+
} else {
|
3003
|
+
kstr = x;
|
3004
|
+
vstr = '';
|
3005
|
+
}
|
3006
|
+
|
3007
|
+
k = decodeURIComponent(kstr);
|
3008
|
+
v = decodeURIComponent(vstr);
|
3009
|
+
|
3010
|
+
if (!hasOwnProperty(obj, k)) {
|
3011
|
+
obj[k] = v;
|
3012
|
+
} else if (isArray(obj[k])) {
|
3013
|
+
obj[k].push(v);
|
3014
|
+
} else {
|
3015
|
+
obj[k] = [obj[k], v];
|
3016
|
+
}
|
3017
|
+
}
|
3018
|
+
|
3019
|
+
return obj;
|
3020
|
+
};
|
3021
|
+
|
3022
|
+
var isArray = Array.isArray || function (xs) {
|
3023
|
+
return Object.prototype.toString.call(xs) === '[object Array]';
|
3024
|
+
};
|
3025
|
+
|
3026
|
+
|
3027
|
+
/***/ }),
|
3028
|
+
|
3029
|
+
/***/ "./node_modules/querystring-es3/encode.js":
|
3030
|
+
/*!************************************************!*\
|
3031
|
+
!*** ./node_modules/querystring-es3/encode.js ***!
|
3032
|
+
\************************************************/
|
3033
|
+
/*! no static exports found */
|
3034
|
+
/***/ (function(module, exports, __webpack_require__) {
|
3035
|
+
|
3036
|
+
"use strict";
|
3037
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
3038
|
+
//
|
3039
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
3040
|
+
// copy of this software and associated documentation files (the
|
3041
|
+
// "Software"), to deal in the Software without restriction, including
|
3042
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
3043
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
3044
|
+
// persons to whom the Software is furnished to do so, subject to the
|
3045
|
+
// following conditions:
|
3046
|
+
//
|
3047
|
+
// The above copyright notice and this permission notice shall be included
|
3048
|
+
// in all copies or substantial portions of the Software.
|
3049
|
+
//
|
3050
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
3051
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
3052
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
3053
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
3054
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
3055
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
3056
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
3057
|
+
|
3058
|
+
|
3059
|
+
|
3060
|
+
var stringifyPrimitive = function(v) {
|
3061
|
+
switch (typeof v) {
|
3062
|
+
case 'string':
|
3063
|
+
return v;
|
3064
|
+
|
3065
|
+
case 'boolean':
|
3066
|
+
return v ? 'true' : 'false';
|
3067
|
+
|
3068
|
+
case 'number':
|
3069
|
+
return isFinite(v) ? v : '';
|
3070
|
+
|
3071
|
+
default:
|
3072
|
+
return '';
|
3073
|
+
}
|
3074
|
+
};
|
3075
|
+
|
3076
|
+
module.exports = function(obj, sep, eq, name) {
|
3077
|
+
sep = sep || '&';
|
3078
|
+
eq = eq || '=';
|
3079
|
+
if (obj === null) {
|
3080
|
+
obj = undefined;
|
3081
|
+
}
|
3082
|
+
|
3083
|
+
if (typeof obj === 'object') {
|
3084
|
+
return map(objectKeys(obj), function(k) {
|
3085
|
+
var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
|
3086
|
+
if (isArray(obj[k])) {
|
3087
|
+
return map(obj[k], function(v) {
|
3088
|
+
return ks + encodeURIComponent(stringifyPrimitive(v));
|
3089
|
+
}).join(sep);
|
3090
|
+
} else {
|
3091
|
+
return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
|
3092
|
+
}
|
3093
|
+
}).join(sep);
|
3094
|
+
|
3095
|
+
}
|
3096
|
+
|
3097
|
+
if (!name) return '';
|
3098
|
+
return encodeURIComponent(stringifyPrimitive(name)) + eq +
|
3099
|
+
encodeURIComponent(stringifyPrimitive(obj));
|
3100
|
+
};
|
3101
|
+
|
3102
|
+
var isArray = Array.isArray || function (xs) {
|
3103
|
+
return Object.prototype.toString.call(xs) === '[object Array]';
|
3104
|
+
};
|
3105
|
+
|
3106
|
+
function map (xs, f) {
|
3107
|
+
if (xs.map) return xs.map(f);
|
3108
|
+
var res = [];
|
3109
|
+
for (var i = 0; i < xs.length; i++) {
|
3110
|
+
res.push(f(xs[i], i));
|
3111
|
+
}
|
3112
|
+
return res;
|
3113
|
+
}
|
3114
|
+
|
3115
|
+
var objectKeys = Object.keys || function (obj) {
|
3116
|
+
var res = [];
|
3117
|
+
for (var key in obj) {
|
3118
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
|
3119
|
+
}
|
3120
|
+
return res;
|
3121
|
+
};
|
3122
|
+
|
3123
|
+
|
3124
|
+
/***/ }),
|
3125
|
+
|
3126
|
+
/***/ "./node_modules/querystring-es3/index.js":
|
3127
|
+
/*!***********************************************!*\
|
3128
|
+
!*** ./node_modules/querystring-es3/index.js ***!
|
3129
|
+
\***********************************************/
|
3130
|
+
/*! no static exports found */
|
3131
|
+
/***/ (function(module, exports, __webpack_require__) {
|
3132
|
+
|
3133
|
+
"use strict";
|
3134
|
+
|
3135
|
+
|
3136
|
+
exports.decode = exports.parse = __webpack_require__(/*! ./decode */ "./node_modules/querystring-es3/decode.js");
|
3137
|
+
exports.encode = exports.stringify = __webpack_require__(/*! ./encode */ "./node_modules/querystring-es3/encode.js");
|
3138
|
+
|
3139
|
+
|
3140
|
+
/***/ }),
|
3141
|
+
|
3142
|
+
/***/ "./node_modules/url/url.js":
|
3143
|
+
/*!*********************************!*\
|
3144
|
+
!*** ./node_modules/url/url.js ***!
|
3145
|
+
\*********************************/
|
3146
|
+
/*! no static exports found */
|
3147
|
+
/***/ (function(module, exports, __webpack_require__) {
|
3148
|
+
|
3149
|
+
"use strict";
|
3150
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
3151
|
+
//
|
3152
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
3153
|
+
// copy of this software and associated documentation files (the
|
3154
|
+
// "Software"), to deal in the Software without restriction, including
|
3155
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
3156
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
3157
|
+
// persons to whom the Software is furnished to do so, subject to the
|
3158
|
+
// following conditions:
|
3159
|
+
//
|
3160
|
+
// The above copyright notice and this permission notice shall be included
|
3161
|
+
// in all copies or substantial portions of the Software.
|
3162
|
+
//
|
3163
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
3164
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
3165
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
3166
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
3167
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
3168
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
3169
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
3170
|
+
|
3171
|
+
|
3172
|
+
|
3173
|
+
var punycode = __webpack_require__(/*! punycode */ "./node_modules/node-libs-browser/node_modules/punycode/punycode.js");
|
3174
|
+
var util = __webpack_require__(/*! ./util */ "./node_modules/url/util.js");
|
3175
|
+
|
3176
|
+
exports.parse = urlParse;
|
3177
|
+
exports.resolve = urlResolve;
|
3178
|
+
exports.resolveObject = urlResolveObject;
|
3179
|
+
exports.format = urlFormat;
|
3180
|
+
|
3181
|
+
exports.Url = Url;
|
3182
|
+
|
3183
|
+
function Url() {
|
3184
|
+
this.protocol = null;
|
3185
|
+
this.slashes = null;
|
3186
|
+
this.auth = null;
|
3187
|
+
this.host = null;
|
3188
|
+
this.port = null;
|
3189
|
+
this.hostname = null;
|
3190
|
+
this.hash = null;
|
3191
|
+
this.search = null;
|
3192
|
+
this.query = null;
|
3193
|
+
this.pathname = null;
|
3194
|
+
this.path = null;
|
3195
|
+
this.href = null;
|
3196
|
+
}
|
3197
|
+
|
3198
|
+
// Reference: RFC 3986, RFC 1808, RFC 2396
|
3199
|
+
|
3200
|
+
// define these here so at least they only have to be
|
3201
|
+
// compiled once on the first module load.
|
3202
|
+
var protocolPattern = /^([a-z0-9.+-]+:)/i,
|
3203
|
+
portPattern = /:[0-9]*$/,
|
3204
|
+
|
3205
|
+
// Special case for a simple path URL
|
3206
|
+
simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
|
3207
|
+
|
3208
|
+
// RFC 2396: characters reserved for delimiting URLs.
|
3209
|
+
// We actually just auto-escape these.
|
3210
|
+
delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
|
3211
|
+
|
3212
|
+
// RFC 2396: characters not allowed for various reasons.
|
3213
|
+
unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
|
3214
|
+
|
3215
|
+
// Allowed by RFCs, but cause of XSS attacks. Always escape these.
|
3216
|
+
autoEscape = ['\''].concat(unwise),
|
3217
|
+
// Characters that are never ever allowed in a hostname.
|
3218
|
+
// Note that any invalid chars are also handled, but these
|
3219
|
+
// are the ones that are *expected* to be seen, so we fast-path
|
3220
|
+
// them.
|
3221
|
+
nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
|
3222
|
+
hostEndingChars = ['/', '?', '#'],
|
3223
|
+
hostnameMaxLen = 255,
|
3224
|
+
hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
|
3225
|
+
hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
|
3226
|
+
// protocols that can allow "unsafe" and "unwise" chars.
|
3227
|
+
unsafeProtocol = {
|
3228
|
+
'javascript': true,
|
3229
|
+
'javascript:': true
|
3230
|
+
},
|
3231
|
+
// protocols that never have a hostname.
|
3232
|
+
hostlessProtocol = {
|
3233
|
+
'javascript': true,
|
3234
|
+
'javascript:': true
|
3235
|
+
},
|
3236
|
+
// protocols that always contain a // bit.
|
3237
|
+
slashedProtocol = {
|
3238
|
+
'http': true,
|
3239
|
+
'https': true,
|
3240
|
+
'ftp': true,
|
3241
|
+
'gopher': true,
|
3242
|
+
'file': true,
|
3243
|
+
'http:': true,
|
3244
|
+
'https:': true,
|
3245
|
+
'ftp:': true,
|
3246
|
+
'gopher:': true,
|
3247
|
+
'file:': true
|
3248
|
+
},
|
3249
|
+
querystring = __webpack_require__(/*! querystring */ "./node_modules/querystring-es3/index.js");
|
3250
|
+
|
3251
|
+
function urlParse(url, parseQueryString, slashesDenoteHost) {
|
3252
|
+
if (url && util.isObject(url) && url instanceof Url) return url;
|
3253
|
+
|
3254
|
+
var u = new Url;
|
3255
|
+
u.parse(url, parseQueryString, slashesDenoteHost);
|
3256
|
+
return u;
|
3257
|
+
}
|
3258
|
+
|
3259
|
+
Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
|
3260
|
+
if (!util.isString(url)) {
|
3261
|
+
throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
|
3262
|
+
}
|
3263
|
+
|
3264
|
+
// Copy chrome, IE, opera backslash-handling behavior.
|
3265
|
+
// Back slashes before the query string get converted to forward slashes
|
3266
|
+
// See: https://code.google.com/p/chromium/issues/detail?id=25916
|
3267
|
+
var queryIndex = url.indexOf('?'),
|
3268
|
+
splitter =
|
3269
|
+
(queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
|
3270
|
+
uSplit = url.split(splitter),
|
3271
|
+
slashRegex = /\\/g;
|
3272
|
+
uSplit[0] = uSplit[0].replace(slashRegex, '/');
|
3273
|
+
url = uSplit.join(splitter);
|
3274
|
+
|
3275
|
+
var rest = url;
|
3276
|
+
|
3277
|
+
// trim before proceeding.
|
3278
|
+
// This is to support parse stuff like " http://foo.com \n"
|
3279
|
+
rest = rest.trim();
|
3280
|
+
|
3281
|
+
if (!slashesDenoteHost && url.split('#').length === 1) {
|
3282
|
+
// Try fast path regexp
|
3283
|
+
var simplePath = simplePathPattern.exec(rest);
|
3284
|
+
if (simplePath) {
|
3285
|
+
this.path = rest;
|
3286
|
+
this.href = rest;
|
3287
|
+
this.pathname = simplePath[1];
|
3288
|
+
if (simplePath[2]) {
|
3289
|
+
this.search = simplePath[2];
|
3290
|
+
if (parseQueryString) {
|
3291
|
+
this.query = querystring.parse(this.search.substr(1));
|
3292
|
+
} else {
|
3293
|
+
this.query = this.search.substr(1);
|
3294
|
+
}
|
3295
|
+
} else if (parseQueryString) {
|
3296
|
+
this.search = '';
|
3297
|
+
this.query = {};
|
3298
|
+
}
|
3299
|
+
return this;
|
3300
|
+
}
|
3301
|
+
}
|
3302
|
+
|
3303
|
+
var proto = protocolPattern.exec(rest);
|
3304
|
+
if (proto) {
|
3305
|
+
proto = proto[0];
|
3306
|
+
var lowerProto = proto.toLowerCase();
|
3307
|
+
this.protocol = lowerProto;
|
3308
|
+
rest = rest.substr(proto.length);
|
3309
|
+
}
|
3310
|
+
|
3311
|
+
// figure out if it's got a host
|
3312
|
+
// user@server is *always* interpreted as a hostname, and url
|
3313
|
+
// resolution will treat //foo/bar as host=foo,path=bar because that's
|
3314
|
+
// how the browser resolves relative URLs.
|
3315
|
+
if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
|
3316
|
+
var slashes = rest.substr(0, 2) === '//';
|
3317
|
+
if (slashes && !(proto && hostlessProtocol[proto])) {
|
3318
|
+
rest = rest.substr(2);
|
3319
|
+
this.slashes = true;
|
3320
|
+
}
|
3321
|
+
}
|
3322
|
+
|
3323
|
+
if (!hostlessProtocol[proto] &&
|
3324
|
+
(slashes || (proto && !slashedProtocol[proto]))) {
|
3325
|
+
|
3326
|
+
// there's a hostname.
|
3327
|
+
// the first instance of /, ?, ;, or # ends the host.
|
3328
|
+
//
|
3329
|
+
// If there is an @ in the hostname, then non-host chars *are* allowed
|
3330
|
+
// to the left of the last @ sign, unless some host-ending character
|
3331
|
+
// comes *before* the @-sign.
|
3332
|
+
// URLs are obnoxious.
|
3333
|
+
//
|
3334
|
+
// ex:
|
3335
|
+
// http://a@b@c/ => user:a@b host:c
|
3336
|
+
// http://a@b?@c => user:a host:c path:/?@c
|
3337
|
+
|
3338
|
+
// v0.12 TODO(isaacs): This is not quite how Chrome does things.
|
3339
|
+
// Review our test case against browsers more comprehensively.
|
3340
|
+
|
3341
|
+
// find the first instance of any hostEndingChars
|
3342
|
+
var hostEnd = -1;
|
3343
|
+
for (var i = 0; i < hostEndingChars.length; i++) {
|
3344
|
+
var hec = rest.indexOf(hostEndingChars[i]);
|
3345
|
+
if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
|
3346
|
+
hostEnd = hec;
|
3347
|
+
}
|
3348
|
+
|
3349
|
+
// at this point, either we have an explicit point where the
|
3350
|
+
// auth portion cannot go past, or the last @ char is the decider.
|
3351
|
+
var auth, atSign;
|
3352
|
+
if (hostEnd === -1) {
|
3353
|
+
// atSign can be anywhere.
|
3354
|
+
atSign = rest.lastIndexOf('@');
|
3355
|
+
} else {
|
3356
|
+
// atSign must be in auth portion.
|
3357
|
+
// http://a@b/c@d => host:b auth:a path:/c@d
|
3358
|
+
atSign = rest.lastIndexOf('@', hostEnd);
|
3359
|
+
}
|
3360
|
+
|
3361
|
+
// Now we have a portion which is definitely the auth.
|
3362
|
+
// Pull that off.
|
3363
|
+
if (atSign !== -1) {
|
3364
|
+
auth = rest.slice(0, atSign);
|
3365
|
+
rest = rest.slice(atSign + 1);
|
3366
|
+
this.auth = decodeURIComponent(auth);
|
3367
|
+
}
|
3368
|
+
|
3369
|
+
// the host is the remaining to the left of the first non-host char
|
3370
|
+
hostEnd = -1;
|
3371
|
+
for (var i = 0; i < nonHostChars.length; i++) {
|
3372
|
+
var hec = rest.indexOf(nonHostChars[i]);
|
3373
|
+
if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
|
3374
|
+
hostEnd = hec;
|
3375
|
+
}
|
3376
|
+
// if we still have not hit it, then the entire thing is a host.
|
3377
|
+
if (hostEnd === -1)
|
3378
|
+
hostEnd = rest.length;
|
3379
|
+
|
3380
|
+
this.host = rest.slice(0, hostEnd);
|
3381
|
+
rest = rest.slice(hostEnd);
|
3382
|
+
|
3383
|
+
// pull out port.
|
3384
|
+
this.parseHost();
|
3385
|
+
|
3386
|
+
// we've indicated that there is a hostname,
|
3387
|
+
// so even if it's empty, it has to be present.
|
3388
|
+
this.hostname = this.hostname || '';
|
3389
|
+
|
3390
|
+
// if hostname begins with [ and ends with ]
|
3391
|
+
// assume that it's an IPv6 address.
|
3392
|
+
var ipv6Hostname = this.hostname[0] === '[' &&
|
3393
|
+
this.hostname[this.hostname.length - 1] === ']';
|
3394
|
+
|
3395
|
+
// validate a little.
|
3396
|
+
if (!ipv6Hostname) {
|
3397
|
+
var hostparts = this.hostname.split(/\./);
|
3398
|
+
for (var i = 0, l = hostparts.length; i < l; i++) {
|
3399
|
+
var part = hostparts[i];
|
3400
|
+
if (!part) continue;
|
3401
|
+
if (!part.match(hostnamePartPattern)) {
|
3402
|
+
var newpart = '';
|
3403
|
+
for (var j = 0, k = part.length; j < k; j++) {
|
3404
|
+
if (part.charCodeAt(j) > 127) {
|
3405
|
+
// we replace non-ASCII char with a temporary placeholder
|
3406
|
+
// we need this to make sure size of hostname is not
|
3407
|
+
// broken by replacing non-ASCII by nothing
|
3408
|
+
newpart += 'x';
|
3409
|
+
} else {
|
3410
|
+
newpart += part[j];
|
3411
|
+
}
|
3412
|
+
}
|
3413
|
+
// we test again with ASCII char only
|
3414
|
+
if (!newpart.match(hostnamePartPattern)) {
|
3415
|
+
var validParts = hostparts.slice(0, i);
|
3416
|
+
var notHost = hostparts.slice(i + 1);
|
3417
|
+
var bit = part.match(hostnamePartStart);
|
3418
|
+
if (bit) {
|
3419
|
+
validParts.push(bit[1]);
|
3420
|
+
notHost.unshift(bit[2]);
|
3421
|
+
}
|
3422
|
+
if (notHost.length) {
|
3423
|
+
rest = '/' + notHost.join('.') + rest;
|
3424
|
+
}
|
3425
|
+
this.hostname = validParts.join('.');
|
3426
|
+
break;
|
3427
|
+
}
|
3428
|
+
}
|
3429
|
+
}
|
3430
|
+
}
|
3431
|
+
|
3432
|
+
if (this.hostname.length > hostnameMaxLen) {
|
3433
|
+
this.hostname = '';
|
3434
|
+
} else {
|
3435
|
+
// hostnames are always lower case.
|
3436
|
+
this.hostname = this.hostname.toLowerCase();
|
3437
|
+
}
|
3438
|
+
|
3439
|
+
if (!ipv6Hostname) {
|
3440
|
+
// IDNA Support: Returns a punycoded representation of "domain".
|
3441
|
+
// It only converts parts of the domain name that
|
3442
|
+
// have non-ASCII characters, i.e. it doesn't matter if
|
3443
|
+
// you call it with a domain that already is ASCII-only.
|
3444
|
+
this.hostname = punycode.toASCII(this.hostname);
|
3445
|
+
}
|
3446
|
+
|
3447
|
+
var p = this.port ? ':' + this.port : '';
|
3448
|
+
var h = this.hostname || '';
|
3449
|
+
this.host = h + p;
|
3450
|
+
this.href += this.host;
|
3451
|
+
|
3452
|
+
// strip [ and ] from the hostname
|
3453
|
+
// the host field still retains them, though
|
3454
|
+
if (ipv6Hostname) {
|
3455
|
+
this.hostname = this.hostname.substr(1, this.hostname.length - 2);
|
3456
|
+
if (rest[0] !== '/') {
|
3457
|
+
rest = '/' + rest;
|
3458
|
+
}
|
3459
|
+
}
|
3460
|
+
}
|
3461
|
+
|
3462
|
+
// now rest is set to the post-host stuff.
|
3463
|
+
// chop off any delim chars.
|
3464
|
+
if (!unsafeProtocol[lowerProto]) {
|
3465
|
+
|
3466
|
+
// First, make 100% sure that any "autoEscape" chars get
|
3467
|
+
// escaped, even if encodeURIComponent doesn't think they
|
3468
|
+
// need to be.
|
3469
|
+
for (var i = 0, l = autoEscape.length; i < l; i++) {
|
3470
|
+
var ae = autoEscape[i];
|
3471
|
+
if (rest.indexOf(ae) === -1)
|
3472
|
+
continue;
|
3473
|
+
var esc = encodeURIComponent(ae);
|
3474
|
+
if (esc === ae) {
|
3475
|
+
esc = escape(ae);
|
3476
|
+
}
|
3477
|
+
rest = rest.split(ae).join(esc);
|
3478
|
+
}
|
3479
|
+
}
|
3480
|
+
|
3481
|
+
|
3482
|
+
// chop off from the tail first.
|
3483
|
+
var hash = rest.indexOf('#');
|
3484
|
+
if (hash !== -1) {
|
3485
|
+
// got a fragment string.
|
3486
|
+
this.hash = rest.substr(hash);
|
3487
|
+
rest = rest.slice(0, hash);
|
3488
|
+
}
|
3489
|
+
var qm = rest.indexOf('?');
|
3490
|
+
if (qm !== -1) {
|
3491
|
+
this.search = rest.substr(qm);
|
3492
|
+
this.query = rest.substr(qm + 1);
|
3493
|
+
if (parseQueryString) {
|
3494
|
+
this.query = querystring.parse(this.query);
|
3495
|
+
}
|
3496
|
+
rest = rest.slice(0, qm);
|
3497
|
+
} else if (parseQueryString) {
|
3498
|
+
// no query string, but parseQueryString still requested
|
3499
|
+
this.search = '';
|
3500
|
+
this.query = {};
|
3501
|
+
}
|
3502
|
+
if (rest) this.pathname = rest;
|
3503
|
+
if (slashedProtocol[lowerProto] &&
|
3504
|
+
this.hostname && !this.pathname) {
|
3505
|
+
this.pathname = '/';
|
3506
|
+
}
|
3507
|
+
|
3508
|
+
//to support http.request
|
3509
|
+
if (this.pathname || this.search) {
|
3510
|
+
var p = this.pathname || '';
|
3511
|
+
var s = this.search || '';
|
3512
|
+
this.path = p + s;
|
3513
|
+
}
|
3514
|
+
|
3515
|
+
// finally, reconstruct the href based on what has been validated.
|
3516
|
+
this.href = this.format();
|
3517
|
+
return this;
|
3518
|
+
};
|
3519
|
+
|
3520
|
+
// format a parsed object into a url string
|
3521
|
+
function urlFormat(obj) {
|
3522
|
+
// ensure it's an object, and not a string url.
|
3523
|
+
// If it's an obj, this is a no-op.
|
3524
|
+
// this way, you can call url_format() on strings
|
3525
|
+
// to clean up potentially wonky urls.
|
3526
|
+
if (util.isString(obj)) obj = urlParse(obj);
|
3527
|
+
if (!(obj instanceof Url)) return Url.prototype.format.call(obj);
|
3528
|
+
return obj.format();
|
3529
|
+
}
|
3530
|
+
|
3531
|
+
Url.prototype.format = function() {
|
3532
|
+
var auth = this.auth || '';
|
3533
|
+
if (auth) {
|
3534
|
+
auth = encodeURIComponent(auth);
|
3535
|
+
auth = auth.replace(/%3A/i, ':');
|
3536
|
+
auth += '@';
|
3537
|
+
}
|
3538
|
+
|
3539
|
+
var protocol = this.protocol || '',
|
3540
|
+
pathname = this.pathname || '',
|
3541
|
+
hash = this.hash || '',
|
3542
|
+
host = false,
|
3543
|
+
query = '';
|
3544
|
+
|
3545
|
+
if (this.host) {
|
3546
|
+
host = auth + this.host;
|
3547
|
+
} else if (this.hostname) {
|
3548
|
+
host = auth + (this.hostname.indexOf(':') === -1 ?
|
3549
|
+
this.hostname :
|
3550
|
+
'[' + this.hostname + ']');
|
3551
|
+
if (this.port) {
|
3552
|
+
host += ':' + this.port;
|
3553
|
+
}
|
3554
|
+
}
|
3555
|
+
|
3556
|
+
if (this.query &&
|
3557
|
+
util.isObject(this.query) &&
|
3558
|
+
Object.keys(this.query).length) {
|
3559
|
+
query = querystring.stringify(this.query);
|
3560
|
+
}
|
3561
|
+
|
3562
|
+
var search = this.search || (query && ('?' + query)) || '';
|
3563
|
+
|
3564
|
+
if (protocol && protocol.substr(-1) !== ':') protocol += ':';
|
3565
|
+
|
3566
|
+
// only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
|
3567
|
+
// unless they had them to begin with.
|
3568
|
+
if (this.slashes ||
|
3569
|
+
(!protocol || slashedProtocol[protocol]) && host !== false) {
|
3570
|
+
host = '//' + (host || '');
|
3571
|
+
if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
|
3572
|
+
} else if (!host) {
|
3573
|
+
host = '';
|
3574
|
+
}
|
3575
|
+
|
3576
|
+
if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
|
3577
|
+
if (search && search.charAt(0) !== '?') search = '?' + search;
|
3578
|
+
|
3579
|
+
pathname = pathname.replace(/[?#]/g, function(match) {
|
3580
|
+
return encodeURIComponent(match);
|
3581
|
+
});
|
3582
|
+
search = search.replace('#', '%23');
|
3583
|
+
|
3584
|
+
return protocol + host + pathname + search + hash;
|
3585
|
+
};
|
3586
|
+
|
3587
|
+
function urlResolve(source, relative) {
|
3588
|
+
return urlParse(source, false, true).resolve(relative);
|
3589
|
+
}
|
3590
|
+
|
3591
|
+
Url.prototype.resolve = function(relative) {
|
3592
|
+
return this.resolveObject(urlParse(relative, false, true)).format();
|
3593
|
+
};
|
3594
|
+
|
3595
|
+
function urlResolveObject(source, relative) {
|
3596
|
+
if (!source) return relative;
|
3597
|
+
return urlParse(source, false, true).resolveObject(relative);
|
3598
|
+
}
|
3599
|
+
|
3600
|
+
Url.prototype.resolveObject = function(relative) {
|
3601
|
+
if (util.isString(relative)) {
|
3602
|
+
var rel = new Url();
|
3603
|
+
rel.parse(relative, false, true);
|
3604
|
+
relative = rel;
|
3605
|
+
}
|
3606
|
+
|
3607
|
+
var result = new Url();
|
3608
|
+
var tkeys = Object.keys(this);
|
3609
|
+
for (var tk = 0; tk < tkeys.length; tk++) {
|
3610
|
+
var tkey = tkeys[tk];
|
3611
|
+
result[tkey] = this[tkey];
|
3612
|
+
}
|
3613
|
+
|
3614
|
+
// hash is always overridden, no matter what.
|
3615
|
+
// even href="" will remove it.
|
3616
|
+
result.hash = relative.hash;
|
3617
|
+
|
3618
|
+
// if the relative url is empty, then there's nothing left to do here.
|
3619
|
+
if (relative.href === '') {
|
3620
|
+
result.href = result.format();
|
3621
|
+
return result;
|
3622
|
+
}
|
3623
|
+
|
3624
|
+
// hrefs like //foo/bar always cut to the protocol.
|
3625
|
+
if (relative.slashes && !relative.protocol) {
|
3626
|
+
// take everything except the protocol from relative
|
3627
|
+
var rkeys = Object.keys(relative);
|
3628
|
+
for (var rk = 0; rk < rkeys.length; rk++) {
|
3629
|
+
var rkey = rkeys[rk];
|
3630
|
+
if (rkey !== 'protocol')
|
3631
|
+
result[rkey] = relative[rkey];
|
3632
|
+
}
|
3633
|
+
|
3634
|
+
//urlParse appends trailing / to urls like http://www.example.com
|
3635
|
+
if (slashedProtocol[result.protocol] &&
|
3636
|
+
result.hostname && !result.pathname) {
|
3637
|
+
result.path = result.pathname = '/';
|
3638
|
+
}
|
3639
|
+
|
3640
|
+
result.href = result.format();
|
3641
|
+
return result;
|
3642
|
+
}
|
3643
|
+
|
3644
|
+
if (relative.protocol && relative.protocol !== result.protocol) {
|
3645
|
+
// if it's a known url protocol, then changing
|
3646
|
+
// the protocol does weird things
|
3647
|
+
// first, if it's not file:, then we MUST have a host,
|
3648
|
+
// and if there was a path
|
3649
|
+
// to begin with, then we MUST have a path.
|
3650
|
+
// if it is file:, then the host is dropped,
|
3651
|
+
// because that's known to be hostless.
|
3652
|
+
// anything else is assumed to be absolute.
|
3653
|
+
if (!slashedProtocol[relative.protocol]) {
|
3654
|
+
var keys = Object.keys(relative);
|
3655
|
+
for (var v = 0; v < keys.length; v++) {
|
3656
|
+
var k = keys[v];
|
3657
|
+
result[k] = relative[k];
|
3658
|
+
}
|
3659
|
+
result.href = result.format();
|
3660
|
+
return result;
|
3661
|
+
}
|
3662
|
+
|
3663
|
+
result.protocol = relative.protocol;
|
3664
|
+
if (!relative.host && !hostlessProtocol[relative.protocol]) {
|
3665
|
+
var relPath = (relative.pathname || '').split('/');
|
3666
|
+
while (relPath.length && !(relative.host = relPath.shift()));
|
3667
|
+
if (!relative.host) relative.host = '';
|
3668
|
+
if (!relative.hostname) relative.hostname = '';
|
3669
|
+
if (relPath[0] !== '') relPath.unshift('');
|
3670
|
+
if (relPath.length < 2) relPath.unshift('');
|
3671
|
+
result.pathname = relPath.join('/');
|
3672
|
+
} else {
|
3673
|
+
result.pathname = relative.pathname;
|
3674
|
+
}
|
3675
|
+
result.search = relative.search;
|
3676
|
+
result.query = relative.query;
|
3677
|
+
result.host = relative.host || '';
|
3678
|
+
result.auth = relative.auth;
|
3679
|
+
result.hostname = relative.hostname || relative.host;
|
3680
|
+
result.port = relative.port;
|
3681
|
+
// to support http.request
|
3682
|
+
if (result.pathname || result.search) {
|
3683
|
+
var p = result.pathname || '';
|
3684
|
+
var s = result.search || '';
|
3685
|
+
result.path = p + s;
|
3686
|
+
}
|
3687
|
+
result.slashes = result.slashes || relative.slashes;
|
3688
|
+
result.href = result.format();
|
3689
|
+
return result;
|
3690
|
+
}
|
3691
|
+
|
3692
|
+
var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
|
3693
|
+
isRelAbs = (
|
3694
|
+
relative.host ||
|
3695
|
+
relative.pathname && relative.pathname.charAt(0) === '/'
|
3696
|
+
),
|
3697
|
+
mustEndAbs = (isRelAbs || isSourceAbs ||
|
3698
|
+
(result.host && relative.pathname)),
|
3699
|
+
removeAllDots = mustEndAbs,
|
3700
|
+
srcPath = result.pathname && result.pathname.split('/') || [],
|
3701
|
+
relPath = relative.pathname && relative.pathname.split('/') || [],
|
3702
|
+
psychotic = result.protocol && !slashedProtocol[result.protocol];
|
3703
|
+
|
3704
|
+
// if the url is a non-slashed url, then relative
|
3705
|
+
// links like ../.. should be able
|
3706
|
+
// to crawl up to the hostname, as well. This is strange.
|
3707
|
+
// result.protocol has already been set by now.
|
3708
|
+
// Later on, put the first path part into the host field.
|
3709
|
+
if (psychotic) {
|
3710
|
+
result.hostname = '';
|
3711
|
+
result.port = null;
|
3712
|
+
if (result.host) {
|
3713
|
+
if (srcPath[0] === '') srcPath[0] = result.host;
|
3714
|
+
else srcPath.unshift(result.host);
|
3715
|
+
}
|
3716
|
+
result.host = '';
|
3717
|
+
if (relative.protocol) {
|
3718
|
+
relative.hostname = null;
|
3719
|
+
relative.port = null;
|
3720
|
+
if (relative.host) {
|
3721
|
+
if (relPath[0] === '') relPath[0] = relative.host;
|
3722
|
+
else relPath.unshift(relative.host);
|
3723
|
+
}
|
3724
|
+
relative.host = null;
|
3725
|
+
}
|
3726
|
+
mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
|
3727
|
+
}
|
3728
|
+
|
3729
|
+
if (isRelAbs) {
|
3730
|
+
// it's absolute.
|
3731
|
+
result.host = (relative.host || relative.host === '') ?
|
3732
|
+
relative.host : result.host;
|
3733
|
+
result.hostname = (relative.hostname || relative.hostname === '') ?
|
3734
|
+
relative.hostname : result.hostname;
|
3735
|
+
result.search = relative.search;
|
3736
|
+
result.query = relative.query;
|
3737
|
+
srcPath = relPath;
|
3738
|
+
// fall through to the dot-handling below.
|
3739
|
+
} else if (relPath.length) {
|
3740
|
+
// it's relative
|
3741
|
+
// throw away the existing file, and take the new path instead.
|
3742
|
+
if (!srcPath) srcPath = [];
|
3743
|
+
srcPath.pop();
|
3744
|
+
srcPath = srcPath.concat(relPath);
|
3745
|
+
result.search = relative.search;
|
3746
|
+
result.query = relative.query;
|
3747
|
+
} else if (!util.isNullOrUndefined(relative.search)) {
|
3748
|
+
// just pull out the search.
|
3749
|
+
// like href='?foo'.
|
3750
|
+
// Put this after the other two cases because it simplifies the booleans
|
3751
|
+
if (psychotic) {
|
3752
|
+
result.hostname = result.host = srcPath.shift();
|
3753
|
+
//occationaly the auth can get stuck only in host
|
3754
|
+
//this especially happens in cases like
|
3755
|
+
//url.resolveObject('mailto:local1@domain1', 'local2@domain2')
|
3756
|
+
var authInHost = result.host && result.host.indexOf('@') > 0 ?
|
3757
|
+
result.host.split('@') : false;
|
3758
|
+
if (authInHost) {
|
3759
|
+
result.auth = authInHost.shift();
|
3760
|
+
result.host = result.hostname = authInHost.shift();
|
3761
|
+
}
|
3762
|
+
}
|
3763
|
+
result.search = relative.search;
|
3764
|
+
result.query = relative.query;
|
3765
|
+
//to support http.request
|
3766
|
+
if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
|
3767
|
+
result.path = (result.pathname ? result.pathname : '') +
|
3768
|
+
(result.search ? result.search : '');
|
3769
|
+
}
|
3770
|
+
result.href = result.format();
|
3771
|
+
return result;
|
3772
|
+
}
|
3773
|
+
|
3774
|
+
if (!srcPath.length) {
|
3775
|
+
// no path at all. easy.
|
3776
|
+
// we've already handled the other stuff above.
|
3777
|
+
result.pathname = null;
|
3778
|
+
//to support http.request
|
3779
|
+
if (result.search) {
|
3780
|
+
result.path = '/' + result.search;
|
3781
|
+
} else {
|
3782
|
+
result.path = null;
|
3783
|
+
}
|
3784
|
+
result.href = result.format();
|
3785
|
+
return result;
|
3786
|
+
}
|
3787
|
+
|
3788
|
+
// if a url ENDs in . or .., then it must get a trailing slash.
|
3789
|
+
// however, if it ends in anything else non-slashy,
|
3790
|
+
// then it must NOT get a trailing slash.
|
3791
|
+
var last = srcPath.slice(-1)[0];
|
3792
|
+
var hasTrailingSlash = (
|
3793
|
+
(result.host || relative.host || srcPath.length > 1) &&
|
3794
|
+
(last === '.' || last === '..') || last === '');
|
3795
|
+
|
3796
|
+
// strip single dots, resolve double dots to parent dir
|
3797
|
+
// if the path tries to go above the root, `up` ends up > 0
|
3798
|
+
var up = 0;
|
3799
|
+
for (var i = srcPath.length; i >= 0; i--) {
|
3800
|
+
last = srcPath[i];
|
3801
|
+
if (last === '.') {
|
3802
|
+
srcPath.splice(i, 1);
|
3803
|
+
} else if (last === '..') {
|
3804
|
+
srcPath.splice(i, 1);
|
3805
|
+
up++;
|
3806
|
+
} else if (up) {
|
3807
|
+
srcPath.splice(i, 1);
|
3808
|
+
up--;
|
3809
|
+
}
|
3810
|
+
}
|
3811
|
+
|
3812
|
+
// if the path is allowed to go above the root, restore leading ..s
|
3813
|
+
if (!mustEndAbs && !removeAllDots) {
|
3814
|
+
for (; up--; up) {
|
3815
|
+
srcPath.unshift('..');
|
3816
|
+
}
|
3817
|
+
}
|
3818
|
+
|
3819
|
+
if (mustEndAbs && srcPath[0] !== '' &&
|
3820
|
+
(!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
|
3821
|
+
srcPath.unshift('');
|
3822
|
+
}
|
3823
|
+
|
3824
|
+
if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
|
3825
|
+
srcPath.push('');
|
3826
|
+
}
|
3827
|
+
|
3828
|
+
var isAbsolute = srcPath[0] === '' ||
|
3829
|
+
(srcPath[0] && srcPath[0].charAt(0) === '/');
|
3830
|
+
|
3831
|
+
// put the host back
|
3832
|
+
if (psychotic) {
|
3833
|
+
result.hostname = result.host = isAbsolute ? '' :
|
3834
|
+
srcPath.length ? srcPath.shift() : '';
|
3835
|
+
//occationaly the auth can get stuck only in host
|
3836
|
+
//this especially happens in cases like
|
3837
|
+
//url.resolveObject('mailto:local1@domain1', 'local2@domain2')
|
3838
|
+
var authInHost = result.host && result.host.indexOf('@') > 0 ?
|
3839
|
+
result.host.split('@') : false;
|
3840
|
+
if (authInHost) {
|
3841
|
+
result.auth = authInHost.shift();
|
3842
|
+
result.host = result.hostname = authInHost.shift();
|
3843
|
+
}
|
3844
|
+
}
|
3845
|
+
|
3846
|
+
mustEndAbs = mustEndAbs || (result.host && srcPath.length);
|
3847
|
+
|
3848
|
+
if (mustEndAbs && !isAbsolute) {
|
3849
|
+
srcPath.unshift('');
|
3850
|
+
}
|
3851
|
+
|
3852
|
+
if (!srcPath.length) {
|
3853
|
+
result.pathname = null;
|
3854
|
+
result.path = null;
|
3855
|
+
} else {
|
3856
|
+
result.pathname = srcPath.join('/');
|
3857
|
+
}
|
3858
|
+
|
3859
|
+
//to support request.http
|
3860
|
+
if (!util.isNull(result.pathname) || !util.isNull(result.search)) {
|
3861
|
+
result.path = (result.pathname ? result.pathname : '') +
|
3862
|
+
(result.search ? result.search : '');
|
3863
|
+
}
|
3864
|
+
result.auth = relative.auth || result.auth;
|
3865
|
+
result.slashes = result.slashes || relative.slashes;
|
3866
|
+
result.href = result.format();
|
3867
|
+
return result;
|
3868
|
+
};
|
3869
|
+
|
3870
|
+
Url.prototype.parseHost = function() {
|
3871
|
+
var host = this.host;
|
3872
|
+
var port = portPattern.exec(host);
|
3873
|
+
if (port) {
|
3874
|
+
port = port[0];
|
3875
|
+
if (port !== ':') {
|
3876
|
+
this.port = port.substr(1);
|
3877
|
+
}
|
3878
|
+
host = host.substr(0, host.length - port.length);
|
3879
|
+
}
|
3880
|
+
if (host) this.hostname = host;
|
3881
|
+
};
|
3882
|
+
|
3883
|
+
|
3884
|
+
/***/ }),
|
3885
|
+
|
3886
|
+
/***/ "./node_modules/url/util.js":
|
3887
|
+
/*!**********************************!*\
|
3888
|
+
!*** ./node_modules/url/util.js ***!
|
3889
|
+
\**********************************/
|
3890
|
+
/*! no static exports found */
|
3891
|
+
/***/ (function(module, exports, __webpack_require__) {
|
3892
|
+
|
3893
|
+
"use strict";
|
3894
|
+
|
3895
|
+
|
3896
|
+
module.exports = {
|
3897
|
+
isString: function(arg) {
|
3898
|
+
return typeof(arg) === 'string';
|
3899
|
+
},
|
3900
|
+
isObject: function(arg) {
|
3901
|
+
return typeof(arg) === 'object' && arg !== null;
|
3902
|
+
},
|
3903
|
+
isNull: function(arg) {
|
3904
|
+
return arg === null;
|
3905
|
+
},
|
3906
|
+
isNullOrUndefined: function(arg) {
|
3907
|
+
return arg == null;
|
3908
|
+
}
|
3909
|
+
};
|
3910
|
+
|
3911
|
+
|
3912
|
+
/***/ }),
|
3913
|
+
|
3914
|
+
/***/ "./node_modules/webpack/buildin/global.js":
|
3915
|
+
/*!***********************************!*\
|
3916
|
+
!*** (webpack)/buildin/global.js ***!
|
3917
|
+
\***********************************/
|
3918
|
+
/*! no static exports found */
|
3919
|
+
/***/ (function(module, exports) {
|
3920
|
+
|
3921
|
+
var g;
|
3922
|
+
|
3923
|
+
// This works in non-strict mode
|
3924
|
+
g = (function() {
|
3925
|
+
return this;
|
3926
|
+
})();
|
3927
|
+
|
3928
|
+
try {
|
3929
|
+
// This works if eval is allowed (see CSP)
|
3930
|
+
g = g || new Function("return this")();
|
3931
|
+
} catch (e) {
|
3932
|
+
// This works if the window reference is available
|
3933
|
+
if (typeof window === "object") g = window;
|
3934
|
+
}
|
3935
|
+
|
3936
|
+
// g can still be undefined, but nothing to do about it...
|
3937
|
+
// We return undefined, instead of nothing here, so it's
|
3938
|
+
// easier to handle this case. if(!global) { ...}
|
3939
|
+
|
3940
|
+
module.exports = g;
|
3941
|
+
|
3942
|
+
|
3943
|
+
/***/ }),
|
3944
|
+
|
3945
|
+
/***/ "./node_modules/webpack/buildin/module.js":
|
3946
|
+
/*!***********************************!*\
|
3947
|
+
!*** (webpack)/buildin/module.js ***!
|
3948
|
+
\***********************************/
|
3949
|
+
/*! no static exports found */
|
3950
|
+
/***/ (function(module, exports) {
|
3951
|
+
|
3952
|
+
module.exports = function(module) {
|
3953
|
+
if (!module.webpackPolyfill) {
|
3954
|
+
module.deprecate = function() {};
|
3955
|
+
module.paths = [];
|
3956
|
+
// module.parent = undefined by default
|
3957
|
+
if (!module.children) module.children = [];
|
3958
|
+
Object.defineProperty(module, "loaded", {
|
3959
|
+
enumerable: true,
|
3960
|
+
get: function() {
|
3961
|
+
return module.l;
|
3962
|
+
}
|
3963
|
+
});
|
3964
|
+
Object.defineProperty(module, "id", {
|
3965
|
+
enumerable: true,
|
3966
|
+
get: function() {
|
3967
|
+
return module.i;
|
3968
|
+
}
|
3969
|
+
});
|
3970
|
+
module.webpackPolyfill = 1;
|
3971
|
+
}
|
3972
|
+
return module;
|
2286
3973
|
};
|
2287
3974
|
|
2288
3975
|
|