axios 1.1.3 → 1.3.3

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.

Potentially problematic release.


This version of axios might be problematic. Click here for more details.

Files changed (47) hide show
  1. package/CHANGELOG.md +298 -75
  2. package/{UPGRADE_GUIDE.md → MIGRATION_GUIDE.md} +1 -1
  3. package/README.md +61 -25
  4. package/dist/axios.js +886 -582
  5. package/dist/axios.js.map +1 -1
  6. package/dist/axios.min.js +1 -1
  7. package/dist/axios.min.js.map +1 -1
  8. package/dist/browser/axios.cjs +3189 -0
  9. package/dist/browser/axios.cjs.map +1 -0
  10. package/dist/esm/axios.js +886 -625
  11. package/dist/esm/axios.js.map +1 -1
  12. package/dist/esm/axios.min.js +1 -1
  13. package/dist/esm/axios.min.js.map +1 -1
  14. package/dist/node/axios.cjs +972 -554
  15. package/dist/node/axios.cjs.map +1 -1
  16. package/index.d.cts +528 -0
  17. package/index.d.ts +116 -56
  18. package/index.js +12 -3
  19. package/lib/adapters/adapters.js +59 -0
  20. package/lib/adapters/http.js +87 -34
  21. package/lib/adapters/xhr.js +7 -4
  22. package/lib/axios.js +13 -3
  23. package/lib/core/Axios.js +10 -8
  24. package/lib/core/AxiosError.js +1 -1
  25. package/lib/core/AxiosHeaders.js +102 -80
  26. package/lib/core/dispatchRequest.js +7 -2
  27. package/lib/core/mergeConfig.js +50 -46
  28. package/lib/defaults/index.js +2 -21
  29. package/lib/env/classes/FormData.js +2 -2
  30. package/lib/env/data.js +1 -1
  31. package/lib/helpers/HttpStatusCode.js +71 -0
  32. package/lib/helpers/ZlibHeaderTransformStream.js +28 -0
  33. package/lib/helpers/formDataToStream.js +111 -0
  34. package/lib/helpers/readBlob.js +15 -0
  35. package/lib/helpers/speedometer.js +1 -1
  36. package/lib/helpers/toFormData.js +5 -15
  37. package/lib/platform/browser/classes/FormData.js +1 -1
  38. package/lib/platform/browser/index.js +20 -0
  39. package/lib/utils.js +107 -9
  40. package/package.json +86 -14
  41. package/bin/ssl_hotfix.js +0 -22
  42. package/gulpfile.js +0 -88
  43. package/karma.conf.cjs +0 -250
  44. package/lib/adapters/index.js +0 -33
  45. package/rollup.config.js +0 -90
  46. package/tsconfig.json +0 -14
  47. package/tslint.json +0 -6
package/dist/esm/axios.js CHANGED
@@ -1,4 +1,4 @@
1
- // Axios v1.1.3 Copyright (c) 2022 Matt Zabriskie and contributors
1
+ // Axios v1.3.3 Copyright (c) 2023 Matt Zabriskie and contributors
2
2
  function bind(fn, thisArg) {
3
3
  return function wrap() {
4
4
  return fn.apply(thisArg, arguments);
@@ -231,7 +231,7 @@ const trim = (str) => str.trim ?
231
231
  * @param {Function} fn The callback to invoke for each item
232
232
  *
233
233
  * @param {Boolean} [allOwnKeys = false]
234
- * @returns {void}
234
+ * @returns {any}
235
235
  */
236
236
  function forEach(obj, fn, {allOwnKeys = false} = {}) {
237
237
  // Don't bother if no value provided
@@ -266,6 +266,28 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
266
266
  }
267
267
  }
268
268
 
269
+ function findKey(obj, key) {
270
+ key = key.toLowerCase();
271
+ const keys = Object.keys(obj);
272
+ let i = keys.length;
273
+ let _key;
274
+ while (i-- > 0) {
275
+ _key = keys[i];
276
+ if (key === _key.toLowerCase()) {
277
+ return _key;
278
+ }
279
+ }
280
+ return null;
281
+ }
282
+
283
+ const _global = (() => {
284
+ /*eslint no-undef:0*/
285
+ if (typeof globalThis !== "undefined") return globalThis;
286
+ return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
287
+ })();
288
+
289
+ const isContextDefined = (context) => !isUndefined(context) && context !== _global;
290
+
269
291
  /**
270
292
  * Accepts varargs expecting each argument to be an object, then
271
293
  * immutably merges the properties of each object and returns result.
@@ -285,16 +307,18 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
285
307
  * @returns {Object} Result of all merge properties
286
308
  */
287
309
  function merge(/* obj1, obj2, obj3, ... */) {
310
+ const {caseless} = isContextDefined(this) && this || {};
288
311
  const result = {};
289
312
  const assignValue = (val, key) => {
290
- if (isPlainObject(result[key]) && isPlainObject(val)) {
291
- result[key] = merge(result[key], val);
313
+ const targetKey = caseless && findKey(result, key) || key;
314
+ if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
315
+ result[targetKey] = merge(result[targetKey], val);
292
316
  } else if (isPlainObject(val)) {
293
- result[key] = merge({}, val);
317
+ result[targetKey] = merge({}, val);
294
318
  } else if (isArray(val)) {
295
- result[key] = val.slice();
319
+ result[targetKey] = val.slice();
296
320
  } else {
297
- result[key] = val;
321
+ result[targetKey] = val;
298
322
  }
299
323
  };
300
324
 
@@ -491,7 +515,7 @@ const matchAll = (regExp, str) => {
491
515
  const isHTMLForm = kindOfTest('HTMLFormElement');
492
516
 
493
517
  const toCamelCase = str => {
494
- return str.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,
518
+ return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
495
519
  function replacer(m, p1, p2) {
496
520
  return p1.toUpperCase() + p2;
497
521
  }
@@ -530,6 +554,11 @@ const reduceDescriptors = (obj, reducer) => {
530
554
 
531
555
  const freezeMethods = (obj) => {
532
556
  reduceDescriptors(obj, (descriptor, name) => {
557
+ // skip restricted props in strict mode
558
+ if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
559
+ return false;
560
+ }
561
+
533
562
  const value = obj[name];
534
563
 
535
564
  if (!isFunction(value)) return;
@@ -543,7 +572,7 @@ const freezeMethods = (obj) => {
543
572
 
544
573
  if (!descriptor.set) {
545
574
  descriptor.set = () => {
546
- throw Error('Can not read-only method \'' + name + '\'');
575
+ throw Error('Can not rewrite read-only method \'' + name + '\'');
547
576
  };
548
577
  }
549
578
  });
@@ -570,6 +599,68 @@ const toFiniteNumber = (value, defaultValue) => {
570
599
  return Number.isFinite(value) ? value : defaultValue;
571
600
  };
572
601
 
602
+ const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
603
+
604
+ const DIGIT = '0123456789';
605
+
606
+ const ALPHABET = {
607
+ DIGIT,
608
+ ALPHA,
609
+ ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
610
+ };
611
+
612
+ const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
613
+ let str = '';
614
+ const {length} = alphabet;
615
+ while (size--) {
616
+ str += alphabet[Math.random() * length|0];
617
+ }
618
+
619
+ return str;
620
+ };
621
+
622
+ /**
623
+ * If the thing is a FormData object, return true, otherwise return false.
624
+ *
625
+ * @param {unknown} thing - The thing to check.
626
+ *
627
+ * @returns {boolean}
628
+ */
629
+ function isSpecCompliantForm(thing) {
630
+ return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
631
+ }
632
+
633
+ const toJSONObject = (obj) => {
634
+ const stack = new Array(10);
635
+
636
+ const visit = (source, i) => {
637
+
638
+ if (isObject(source)) {
639
+ if (stack.indexOf(source) >= 0) {
640
+ return;
641
+ }
642
+
643
+ if(!('toJSON' in source)) {
644
+ stack[i] = source;
645
+ const target = isArray(source) ? [] : {};
646
+
647
+ forEach(source, (value, key) => {
648
+ const reducedValue = visit(value, i + 1);
649
+ !isUndefined(reducedValue) && (target[key] = reducedValue);
650
+ });
651
+
652
+ stack[i] = undefined;
653
+
654
+ return target;
655
+ }
656
+ }
657
+
658
+ return source;
659
+ };
660
+
661
+ return visit(obj, 0);
662
+ };
663
+
573
664
  const utils = {
574
665
  isArray,
575
666
  isArrayBuffer,
@@ -612,7 +703,14 @@ const utils = {
612
703
  toObjectSet,
613
704
  toCamelCase,
614
705
  noop,
615
- toFiniteNumber
706
+ toFiniteNumber,
707
+ findKey,
708
+ global: _global,
709
+ isContextDefined,
710
+ ALPHABET,
711
+ generateString,
712
+ isSpecCompliantForm,
713
+ toJSONObject
616
714
  };
617
715
 
618
716
  /**
@@ -626,7 +724,7 @@ const utils = {
626
724
  *
627
725
  * @returns {Error} The created error.
628
726
  */
629
- function AxiosError(message, code, config, request, response) {
727
+ function AxiosError$1(message, code, config, request, response) {
630
728
  Error.call(this);
631
729
 
632
730
  if (Error.captureStackTrace) {
@@ -643,7 +741,7 @@ function AxiosError(message, code, config, request, response) {
643
741
  response && (this.response = response);
644
742
  }
645
743
 
646
- utils.inherits(AxiosError, Error, {
744
+ utils.inherits(AxiosError$1, Error, {
647
745
  toJSON: function toJSON() {
648
746
  return {
649
747
  // Standard
@@ -658,14 +756,14 @@ utils.inherits(AxiosError, Error, {
658
756
  columnNumber: this.columnNumber,
659
757
  stack: this.stack,
660
758
  // Axios
661
- config: this.config,
759
+ config: utils.toJSONObject(this.config),
662
760
  code: this.code,
663
761
  status: this.response && this.response.status ? this.response.status : null
664
762
  };
665
763
  }
666
764
  });
667
765
 
668
- const prototype$1 = AxiosError.prototype;
766
+ const prototype$1 = AxiosError$1.prototype;
669
767
  const descriptors = {};
670
768
 
671
769
  [
@@ -686,11 +784,11 @@ const descriptors = {};
686
784
  descriptors[code] = {value: code};
687
785
  });
688
786
 
689
- Object.defineProperties(AxiosError, descriptors);
787
+ Object.defineProperties(AxiosError$1, descriptors);
690
788
  Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
691
789
 
692
790
  // eslint-disable-next-line func-names
693
- AxiosError.from = (error, code, config, request, response, customProps) => {
791
+ AxiosError$1.from = (error, code, config, request, response, customProps) => {
694
792
  const axiosError = Object.create(prototype$1);
695
793
 
696
794
  utils.toFlatObject(error, axiosError, function filter(obj) {
@@ -699,7 +797,7 @@ AxiosError.from = (error, code, config, request, response, customProps) => {
699
797
  return prop !== 'isAxiosError';
700
798
  });
701
799
 
702
- AxiosError.call(axiosError, error.message, code, config, request, response);
800
+ AxiosError$1.call(axiosError, error.message, code, config, request, response);
703
801
 
704
802
  axiosError.cause = error;
705
803
 
@@ -710,8 +808,8 @@ AxiosError.from = (error, code, config, request, response, customProps) => {
710
808
  return axiosError;
711
809
  };
712
810
 
713
- /* eslint-env browser */
714
- var browser = typeof self == 'object' ? self.FormData : window.FormData;
811
+ // eslint-disable-next-line strict
812
+ const httpAdapter = null;
715
813
 
716
814
  /**
717
815
  * Determines if the given thing is a array or js object.
@@ -768,17 +866,6 @@ const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
768
866
  return /^is[A-Z]/.test(prop);
769
867
  });
770
868
 
771
- /**
772
- * If the thing is a FormData object, return true, otherwise return false.
773
- *
774
- * @param {unknown} thing - The thing to check.
775
- *
776
- * @returns {boolean}
777
- */
778
- function isSpecCompliant(thing) {
779
- return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
780
- }
781
-
782
869
  /**
783
870
  * Convert a data object to FormData
784
871
  *
@@ -802,13 +889,13 @@ function isSpecCompliant(thing) {
802
889
  *
803
890
  * @returns
804
891
  */
805
- function toFormData(obj, formData, options) {
892
+ function toFormData$1(obj, formData, options) {
806
893
  if (!utils.isObject(obj)) {
807
894
  throw new TypeError('target must be an object');
808
895
  }
809
896
 
810
897
  // eslint-disable-next-line no-param-reassign
811
- formData = formData || new (browser || FormData)();
898
+ formData = formData || new (FormData)();
812
899
 
813
900
  // eslint-disable-next-line no-param-reassign
814
901
  options = utils.toFlatObject(options, {
@@ -826,7 +913,7 @@ function toFormData(obj, formData, options) {
826
913
  const dots = options.dots;
827
914
  const indexes = options.indexes;
828
915
  const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
829
- const useBlob = _Blob && isSpecCompliant(formData);
916
+ const useBlob = _Blob && utils.isSpecCompliantForm(formData);
830
917
 
831
918
  if (!utils.isFunction(visitor)) {
832
919
  throw new TypeError('visitor must be a function');
@@ -840,7 +927,7 @@ function toFormData(obj, formData, options) {
840
927
  }
841
928
 
842
929
  if (!useBlob && utils.isBlob(value)) {
843
- throw new AxiosError('Blob is not supported. Use a Buffer instead.');
930
+ throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
844
931
  }
845
932
 
846
933
  if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
@@ -871,7 +958,7 @@ function toFormData(obj, formData, options) {
871
958
  value = JSON.stringify(value);
872
959
  } else if (
873
960
  (utils.isArray(value) && isFlatArray(value)) ||
874
- (utils.isFileList(value) || utils.endsWith(key, '[]') && (arr = utils.toArray(value))
961
+ ((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))
875
962
  )) {
876
963
  // eslint-disable-next-line no-param-reassign
877
964
  key = removeBrackets(key);
@@ -969,7 +1056,7 @@ function encode$1(str) {
969
1056
  function AxiosURLSearchParams(params, options) {
970
1057
  this._pairs = [];
971
1058
 
972
- params && toFormData(params, this, options);
1059
+ params && toFormData$1(params, this, options);
973
1060
  }
974
1061
 
975
1062
  const prototype = AxiosURLSearchParams.prototype;
@@ -1113,6 +1200,8 @@ class InterceptorManager {
1113
1200
  }
1114
1201
  }
1115
1202
 
1203
+ const InterceptorManager$1 = InterceptorManager;
1204
+
1116
1205
  const transitionalDefaults = {
1117
1206
  silentJSONParsing: true,
1118
1207
  forcedJSONParsing: true,
@@ -1121,7 +1210,7 @@ const transitionalDefaults = {
1121
1210
 
1122
1211
  const URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
1123
1212
 
1124
- const FormData$1 = FormData;
1213
+ const FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
1125
1214
 
1126
1215
  /**
1127
1216
  * Determine if we're running in a standard browser environment
@@ -1153,6 +1242,25 @@ const isStandardBrowserEnv = (() => {
1153
1242
  return typeof window !== 'undefined' && typeof document !== 'undefined';
1154
1243
  })();
1155
1244
 
1245
+ /**
1246
+ * Determine if we're running in a standard browser webWorker environment
1247
+ *
1248
+ * Although the `isStandardBrowserEnv` method indicates that
1249
+ * `allows axios to run in a web worker`, the WebWorker will still be
1250
+ * filtered out due to its judgment standard
1251
+ * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
1252
+ * This leads to a problem when axios post `FormData` in webWorker
1253
+ */
1254
+ const isStandardBrowserWebWorkerEnv = (() => {
1255
+ return (
1256
+ typeof WorkerGlobalScope !== 'undefined' &&
1257
+ // eslint-disable-next-line no-undef
1258
+ self instanceof WorkerGlobalScope &&
1259
+ typeof self.importScripts === 'function'
1260
+ );
1261
+ })();
1262
+
1263
+
1156
1264
  const platform = {
1157
1265
  isBrowser: true,
1158
1266
  classes: {
@@ -1161,11 +1269,12 @@ const platform = {
1161
1269
  Blob
1162
1270
  },
1163
1271
  isStandardBrowserEnv,
1272
+ isStandardBrowserWebWorkerEnv,
1164
1273
  protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
1165
1274
  };
1166
1275
 
1167
1276
  function toURLEncodedForm(data, options) {
1168
- return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
1277
+ return toFormData$1(data, new platform.classes.URLSearchParams(), Object.assign({
1169
1278
  visitor: function(value, key, path, helpers) {
1170
1279
  if (platform.isNode && utils.isBuffer(value)) {
1171
1280
  this.append(key, value.toString('base64'));
@@ -1264,209 +1373,162 @@ function formDataToJSON(formData) {
1264
1373
  return null;
1265
1374
  }
1266
1375
 
1376
+ const DEFAULT_CONTENT_TYPE = {
1377
+ 'Content-Type': undefined
1378
+ };
1379
+
1267
1380
  /**
1268
- * Resolve or reject a Promise based on response status.
1381
+ * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1382
+ * of the input
1269
1383
  *
1270
- * @param {Function} resolve A function that resolves the promise.
1271
- * @param {Function} reject A function that rejects the promise.
1272
- * @param {object} response The response.
1384
+ * @param {any} rawValue - The value to be stringified.
1385
+ * @param {Function} parser - A function that parses a string into a JavaScript object.
1386
+ * @param {Function} encoder - A function that takes a value and returns a string.
1273
1387
  *
1274
- * @returns {object} The response.
1388
+ * @returns {string} A stringified version of the rawValue.
1275
1389
  */
1276
- function settle(resolve, reject, response) {
1277
- const validateStatus = response.config.validateStatus;
1278
- if (!response.status || !validateStatus || validateStatus(response.status)) {
1279
- resolve(response);
1280
- } else {
1281
- reject(new AxiosError(
1282
- 'Request failed with status code ' + response.status,
1283
- [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
1284
- response.config,
1285
- response.request,
1286
- response
1287
- ));
1390
+ function stringifySafely(rawValue, parser, encoder) {
1391
+ if (utils.isString(rawValue)) {
1392
+ try {
1393
+ (parser || JSON.parse)(rawValue);
1394
+ return utils.trim(rawValue);
1395
+ } catch (e) {
1396
+ if (e.name !== 'SyntaxError') {
1397
+ throw e;
1398
+ }
1399
+ }
1288
1400
  }
1401
+
1402
+ return (encoder || JSON.stringify)(rawValue);
1289
1403
  }
1290
1404
 
1291
- const cookies = platform.isStandardBrowserEnv ?
1405
+ const defaults = {
1292
1406
 
1293
- // Standard browser envs support document.cookie
1294
- (function standardBrowserEnv() {
1295
- return {
1296
- write: function write(name, value, expires, path, domain, secure) {
1297
- const cookie = [];
1298
- cookie.push(name + '=' + encodeURIComponent(value));
1407
+ transitional: transitionalDefaults,
1299
1408
 
1300
- if (utils.isNumber(expires)) {
1301
- cookie.push('expires=' + new Date(expires).toGMTString());
1302
- }
1409
+ adapter: ['xhr', 'http'],
1303
1410
 
1304
- if (utils.isString(path)) {
1305
- cookie.push('path=' + path);
1306
- }
1411
+ transformRequest: [function transformRequest(data, headers) {
1412
+ const contentType = headers.getContentType() || '';
1413
+ const hasJSONContentType = contentType.indexOf('application/json') > -1;
1414
+ const isObjectPayload = utils.isObject(data);
1307
1415
 
1308
- if (utils.isString(domain)) {
1309
- cookie.push('domain=' + domain);
1310
- }
1416
+ if (isObjectPayload && utils.isHTMLForm(data)) {
1417
+ data = new FormData(data);
1418
+ }
1311
1419
 
1312
- if (secure === true) {
1313
- cookie.push('secure');
1314
- }
1420
+ const isFormData = utils.isFormData(data);
1315
1421
 
1316
- document.cookie = cookie.join('; ');
1317
- },
1422
+ if (isFormData) {
1423
+ if (!hasJSONContentType) {
1424
+ return data;
1425
+ }
1426
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1427
+ }
1318
1428
 
1319
- read: function read(name) {
1320
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1321
- return (match ? decodeURIComponent(match[3]) : null);
1322
- },
1429
+ if (utils.isArrayBuffer(data) ||
1430
+ utils.isBuffer(data) ||
1431
+ utils.isStream(data) ||
1432
+ utils.isFile(data) ||
1433
+ utils.isBlob(data)
1434
+ ) {
1435
+ return data;
1436
+ }
1437
+ if (utils.isArrayBufferView(data)) {
1438
+ return data.buffer;
1439
+ }
1440
+ if (utils.isURLSearchParams(data)) {
1441
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1442
+ return data.toString();
1443
+ }
1323
1444
 
1324
- remove: function remove(name) {
1325
- this.write(name, '', Date.now() - 86400000);
1445
+ let isFileList;
1446
+
1447
+ if (isObjectPayload) {
1448
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
1449
+ return toURLEncodedForm(data, this.formSerializer).toString();
1326
1450
  }
1327
- };
1328
- })() :
1329
1451
 
1330
- // Non standard browser env (web workers, react-native) lack needed support.
1331
- (function nonStandardBrowserEnv() {
1332
- return {
1333
- write: function write() {},
1334
- read: function read() { return null; },
1335
- remove: function remove() {}
1336
- };
1337
- })();
1452
+ if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1453
+ const _FormData = this.env && this.env.FormData;
1338
1454
 
1339
- /**
1340
- * Determines whether the specified URL is absolute
1341
- *
1342
- * @param {string} url The URL to test
1343
- *
1344
- * @returns {boolean} True if the specified URL is absolute, otherwise false
1345
- */
1346
- function isAbsoluteURL(url) {
1347
- // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
1348
- // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
1349
- // by any combination of letters, digits, plus, period, or hyphen.
1350
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
1351
- }
1455
+ return toFormData$1(
1456
+ isFileList ? {'files[]': data} : data,
1457
+ _FormData && new _FormData(),
1458
+ this.formSerializer
1459
+ );
1460
+ }
1461
+ }
1352
1462
 
1353
- /**
1354
- * Creates a new URL by combining the specified URLs
1355
- *
1356
- * @param {string} baseURL The base URL
1357
- * @param {string} relativeURL The relative URL
1358
- *
1359
- * @returns {string} The combined URL
1360
- */
1361
- function combineURLs(baseURL, relativeURL) {
1362
- return relativeURL
1363
- ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
1364
- : baseURL;
1365
- }
1463
+ if (isObjectPayload || hasJSONContentType ) {
1464
+ headers.setContentType('application/json', false);
1465
+ return stringifySafely(data);
1466
+ }
1366
1467
 
1367
- /**
1368
- * Creates a new URL by combining the baseURL with the requestedURL,
1369
- * only when the requestedURL is not already an absolute URL.
1370
- * If the requestURL is absolute, this function returns the requestedURL untouched.
1371
- *
1372
- * @param {string} baseURL The base URL
1373
- * @param {string} requestedURL Absolute or relative URL to combine
1374
- *
1375
- * @returns {string} The combined full path
1376
- */
1377
- function buildFullPath(baseURL, requestedURL) {
1378
- if (baseURL && !isAbsoluteURL(requestedURL)) {
1379
- return combineURLs(baseURL, requestedURL);
1380
- }
1381
- return requestedURL;
1382
- }
1468
+ return data;
1469
+ }],
1383
1470
 
1384
- const isURLSameOrigin = platform.isStandardBrowserEnv ?
1471
+ transformResponse: [function transformResponse(data) {
1472
+ const transitional = this.transitional || defaults.transitional;
1473
+ const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1474
+ const JSONRequested = this.responseType === 'json';
1385
1475
 
1386
- // Standard browser envs have full support of the APIs needed to test
1387
- // whether the request URL is of the same origin as current location.
1388
- (function standardBrowserEnv() {
1389
- const msie = /(msie|trident)/i.test(navigator.userAgent);
1390
- const urlParsingNode = document.createElement('a');
1391
- let originURL;
1476
+ if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
1477
+ const silentJSONParsing = transitional && transitional.silentJSONParsing;
1478
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
1392
1479
 
1393
- /**
1394
- * Parse a URL to discover it's components
1395
- *
1396
- * @param {String} url The URL to be parsed
1397
- * @returns {Object}
1398
- */
1399
- function resolveURL(url) {
1400
- let href = url;
1401
-
1402
- if (msie) {
1403
- // IE needs attribute set twice to normalize properties
1404
- urlParsingNode.setAttribute('href', href);
1405
- href = urlParsingNode.href;
1480
+ try {
1481
+ return JSON.parse(data);
1482
+ } catch (e) {
1483
+ if (strictJSONParsing) {
1484
+ if (e.name === 'SyntaxError') {
1485
+ throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
1486
+ }
1487
+ throw e;
1488
+ }
1406
1489
  }
1490
+ }
1407
1491
 
1408
- urlParsingNode.setAttribute('href', href);
1492
+ return data;
1493
+ }],
1409
1494
 
1410
- // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
1411
- return {
1412
- href: urlParsingNode.href,
1413
- protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
1414
- host: urlParsingNode.host,
1415
- search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
1416
- hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
1417
- hostname: urlParsingNode.hostname,
1418
- port: urlParsingNode.port,
1419
- pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
1420
- urlParsingNode.pathname :
1421
- '/' + urlParsingNode.pathname
1422
- };
1423
- }
1495
+ /**
1496
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
1497
+ * timeout is not created.
1498
+ */
1499
+ timeout: 0,
1424
1500
 
1425
- originURL = resolveURL(window.location.href);
1501
+ xsrfCookieName: 'XSRF-TOKEN',
1502
+ xsrfHeaderName: 'X-XSRF-TOKEN',
1426
1503
 
1427
- /**
1428
- * Determine if a URL shares the same origin as the current location
1429
- *
1430
- * @param {String} requestURL The URL to test
1431
- * @returns {boolean} True if URL shares the same origin, otherwise false
1432
- */
1433
- return function isURLSameOrigin(requestURL) {
1434
- const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
1435
- return (parsed.protocol === originURL.protocol &&
1436
- parsed.host === originURL.host);
1437
- };
1438
- })() :
1504
+ maxContentLength: -1,
1505
+ maxBodyLength: -1,
1439
1506
 
1440
- // Non standard browser envs (web workers, react-native) lack needed support.
1441
- (function nonStandardBrowserEnv() {
1442
- return function isURLSameOrigin() {
1443
- return true;
1444
- };
1445
- })();
1507
+ env: {
1508
+ FormData: platform.classes.FormData,
1509
+ Blob: platform.classes.Blob
1510
+ },
1446
1511
 
1447
- /**
1448
- * A `CanceledError` is an object that is thrown when an operation is canceled.
1449
- *
1450
- * @param {string=} message The message.
1451
- * @param {Object=} config The config.
1452
- * @param {Object=} request The request.
1453
- *
1454
- * @returns {CanceledError} The created error.
1455
- */
1456
- function CanceledError(message, config, request) {
1457
- // eslint-disable-next-line no-eq-null,eqeqeq
1458
- AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
1459
- this.name = 'CanceledError';
1460
- }
1512
+ validateStatus: function validateStatus(status) {
1513
+ return status >= 200 && status < 300;
1514
+ },
1461
1515
 
1462
- utils.inherits(CanceledError, AxiosError, {
1463
- __CANCEL__: true
1516
+ headers: {
1517
+ common: {
1518
+ 'Accept': 'application/json, text/plain, */*'
1519
+ }
1520
+ }
1521
+ };
1522
+
1523
+ utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
1524
+ defaults.headers[method] = {};
1464
1525
  });
1465
1526
 
1466
- function parseProtocol(url) {
1467
- const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
1468
- return match && match[1] || '';
1469
- }
1527
+ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1528
+ defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
1529
+ });
1530
+
1531
+ const defaults$1 = defaults;
1470
1532
 
1471
1533
  // RawAxiosHeaders whose duplicates are ignored by node
1472
1534
  // c.f. https://nodejs.org/api/http.html#http_message_headers
@@ -1521,7 +1583,6 @@ const parseHeaders = rawHeaders => {
1521
1583
  };
1522
1584
 
1523
1585
  const $internals = Symbol('internals');
1524
- const $defaults = Symbol('defaults');
1525
1586
 
1526
1587
  function normalizeHeader(header) {
1527
1588
  return header && String(header).trim().toLowerCase();
@@ -1547,11 +1608,19 @@ function parseTokens(str) {
1547
1608
  return tokens;
1548
1609
  }
1549
1610
 
1550
- function matchHeaderValue(context, value, header, filter) {
1611
+ function isValidHeaderName(str) {
1612
+ return /^[-_a-zA-Z]+$/.test(str.trim());
1613
+ }
1614
+
1615
+ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1551
1616
  if (utils.isFunction(filter)) {
1552
1617
  return filter.call(this, value, header);
1553
1618
  }
1554
1619
 
1620
+ if (isHeaderNameFilter) {
1621
+ value = header;
1622
+ }
1623
+
1555
1624
  if (!utils.isString(value)) return;
1556
1625
 
1557
1626
  if (utils.isString(filter)) {
@@ -1583,27 +1652,12 @@ function buildAccessors(obj, header) {
1583
1652
  });
1584
1653
  }
1585
1654
 
1586
- function findKey(obj, key) {
1587
- key = key.toLowerCase();
1588
- const keys = Object.keys(obj);
1589
- let i = keys.length;
1590
- let _key;
1591
- while (i-- > 0) {
1592
- _key = keys[i];
1593
- if (key === _key.toLowerCase()) {
1594
- return _key;
1595
- }
1655
+ class AxiosHeaders$1 {
1656
+ constructor(headers) {
1657
+ headers && this.set(headers);
1596
1658
  }
1597
- return null;
1598
- }
1599
-
1600
- function AxiosHeaders(headers, defaults) {
1601
- headers && this.set(headers);
1602
- this[$defaults] = defaults || null;
1603
- }
1604
1659
 
1605
- Object.assign(AxiosHeaders.prototype, {
1606
- set: function(header, valueOrRewrite, rewrite) {
1660
+ set(header, valueOrRewrite, rewrite) {
1607
1661
  const self = this;
1608
1662
 
1609
1663
  function setHeader(_value, _header, _rewrite) {
@@ -1613,69 +1667,70 @@ Object.assign(AxiosHeaders.prototype, {
1613
1667
  throw new Error('header name must be a non-empty string');
1614
1668
  }
1615
1669
 
1616
- const key = findKey(self, lHeader);
1670
+ const key = utils.findKey(self, lHeader);
1617
1671
 
1618
- if (key && _rewrite !== true && (self[key] === false || _rewrite === false)) {
1619
- return;
1672
+ if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
1673
+ self[key || _header] = normalizeValue(_value);
1620
1674
  }
1621
-
1622
- self[key || _header] = normalizeValue(_value);
1623
1675
  }
1624
1676
 
1625
- if (utils.isPlainObject(header)) {
1626
- utils.forEach(header, (_value, _header) => {
1627
- setHeader(_value, _header, valueOrRewrite);
1628
- });
1677
+ const setHeaders = (headers, _rewrite) =>
1678
+ utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
1679
+
1680
+ if (utils.isPlainObject(header) || header instanceof this.constructor) {
1681
+ setHeaders(header, valueOrRewrite);
1682
+ } else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1683
+ setHeaders(parseHeaders(header), valueOrRewrite);
1629
1684
  } else {
1630
- setHeader(valueOrRewrite, header, rewrite);
1685
+ header != null && setHeader(valueOrRewrite, header, rewrite);
1631
1686
  }
1632
1687
 
1633
1688
  return this;
1634
- },
1689
+ }
1635
1690
 
1636
- get: function(header, parser) {
1691
+ get(header, parser) {
1637
1692
  header = normalizeHeader(header);
1638
1693
 
1639
- if (!header) return undefined;
1694
+ if (header) {
1695
+ const key = utils.findKey(this, header);
1640
1696
 
1641
- const key = findKey(this, header);
1697
+ if (key) {
1698
+ const value = this[key];
1642
1699
 
1643
- if (key) {
1644
- const value = this[key];
1700
+ if (!parser) {
1701
+ return value;
1702
+ }
1645
1703
 
1646
- if (!parser) {
1647
- return value;
1648
- }
1704
+ if (parser === true) {
1705
+ return parseTokens(value);
1706
+ }
1649
1707
 
1650
- if (parser === true) {
1651
- return parseTokens(value);
1652
- }
1708
+ if (utils.isFunction(parser)) {
1709
+ return parser.call(this, value, key);
1710
+ }
1653
1711
 
1654
- if (utils.isFunction(parser)) {
1655
- return parser.call(this, value, key);
1656
- }
1712
+ if (utils.isRegExp(parser)) {
1713
+ return parser.exec(value);
1714
+ }
1657
1715
 
1658
- if (utils.isRegExp(parser)) {
1659
- return parser.exec(value);
1716
+ throw new TypeError('parser must be boolean|regexp|function');
1660
1717
  }
1661
-
1662
- throw new TypeError('parser must be boolean|regexp|function');
1663
1718
  }
1664
- },
1719
+ }
1665
1720
 
1666
- has: function(header, matcher) {
1721
+ has(header, matcher) {
1667
1722
  header = normalizeHeader(header);
1668
1723
 
1669
1724
  if (header) {
1670
- const key = findKey(this, header);
1725
+ const key = utils.findKey(this, header);
1671
1726
 
1672
- return !!(key && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1727
+ return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1673
1728
  }
1674
1729
 
1675
1730
  return false;
1676
- },
1731
+ }
1677
1732
 
1678
- delete: function(header, matcher) {
1733
+ delete(header, matcher) {
1679
1734
  const self = this;
1680
1735
  let deleted = false;
1681
1736
 
@@ -1683,7 +1738,7 @@ Object.assign(AxiosHeaders.prototype, {
1683
1738
  _header = normalizeHeader(_header);
1684
1739
 
1685
1740
  if (_header) {
1686
- const key = findKey(self, _header);
1741
+ const key = utils.findKey(self, _header);
1687
1742
 
1688
1743
  if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
1689
1744
  delete self[key];
@@ -1700,18 +1755,30 @@ Object.assign(AxiosHeaders.prototype, {
1700
1755
  }
1701
1756
 
1702
1757
  return deleted;
1703
- },
1758
+ }
1704
1759
 
1705
- clear: function() {
1706
- return Object.keys(this).forEach(this.delete.bind(this));
1707
- },
1760
+ clear(matcher) {
1761
+ const keys = Object.keys(this);
1762
+ let i = keys.length;
1763
+ let deleted = false;
1764
+
1765
+ while (i--) {
1766
+ const key = keys[i];
1767
+ if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1768
+ delete this[key];
1769
+ deleted = true;
1770
+ }
1771
+ }
1772
+
1773
+ return deleted;
1774
+ }
1708
1775
 
1709
- normalize: function(format) {
1776
+ normalize(format) {
1710
1777
  const self = this;
1711
1778
  const headers = {};
1712
1779
 
1713
1780
  utils.forEach(this, (value, header) => {
1714
- const key = findKey(headers, header);
1781
+ const key = utils.findKey(headers, header);
1715
1782
 
1716
1783
  if (key) {
1717
1784
  self[key] = normalizeValue(value);
@@ -1731,56 +1798,306 @@ Object.assign(AxiosHeaders.prototype, {
1731
1798
  });
1732
1799
 
1733
1800
  return this;
1734
- },
1801
+ }
1735
1802
 
1736
- toJSON: function(asStrings) {
1803
+ concat(...targets) {
1804
+ return this.constructor.concat(this, ...targets);
1805
+ }
1806
+
1807
+ toJSON(asStrings) {
1737
1808
  const obj = Object.create(null);
1738
1809
 
1739
- utils.forEach(Object.assign({}, this[$defaults] || null, this),
1740
- (value, header) => {
1741
- if (value == null || value === false) return;
1742
- obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value;
1743
- });
1810
+ utils.forEach(this, (value, header) => {
1811
+ value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);
1812
+ });
1744
1813
 
1745
1814
  return obj;
1746
1815
  }
1747
- });
1748
1816
 
1749
- Object.assign(AxiosHeaders, {
1750
- from: function(thing) {
1751
- if (utils.isString(thing)) {
1752
- return new this(parseHeaders(thing));
1753
- }
1817
+ [Symbol.iterator]() {
1818
+ return Object.entries(this.toJSON())[Symbol.iterator]();
1819
+ }
1820
+
1821
+ toString() {
1822
+ return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
1823
+ }
1824
+
1825
+ get [Symbol.toStringTag]() {
1826
+ return 'AxiosHeaders';
1827
+ }
1828
+
1829
+ static from(thing) {
1754
1830
  return thing instanceof this ? thing : new this(thing);
1755
- },
1831
+ }
1832
+
1833
+ static concat(first, ...targets) {
1834
+ const computed = new this(first);
1835
+
1836
+ targets.forEach((target) => computed.set(target));
1837
+
1838
+ return computed;
1839
+ }
1756
1840
 
1757
- accessor: function(header) {
1841
+ static accessor(header) {
1758
1842
  const internals = this[$internals] = (this[$internals] = {
1759
1843
  accessors: {}
1760
1844
  });
1761
1845
 
1762
- const accessors = internals.accessors;
1763
- const prototype = this.prototype;
1846
+ const accessors = internals.accessors;
1847
+ const prototype = this.prototype;
1848
+
1849
+ function defineAccessor(_header) {
1850
+ const lHeader = normalizeHeader(_header);
1851
+
1852
+ if (!accessors[lHeader]) {
1853
+ buildAccessors(prototype, _header);
1854
+ accessors[lHeader] = true;
1855
+ }
1856
+ }
1857
+
1858
+ utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1859
+
1860
+ return this;
1861
+ }
1862
+ }
1863
+
1864
+ AxiosHeaders$1.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
1865
+
1866
+ utils.freezeMethods(AxiosHeaders$1.prototype);
1867
+ utils.freezeMethods(AxiosHeaders$1);
1868
+
1869
+ const AxiosHeaders$2 = AxiosHeaders$1;
1870
+
1871
+ /**
1872
+ * Transform the data for a request or a response
1873
+ *
1874
+ * @param {Array|Function} fns A single function or Array of functions
1875
+ * @param {?Object} response The response object
1876
+ *
1877
+ * @returns {*} The resulting transformed data
1878
+ */
1879
+ function transformData(fns, response) {
1880
+ const config = this || defaults$1;
1881
+ const context = response || config;
1882
+ const headers = AxiosHeaders$2.from(context.headers);
1883
+ let data = context.data;
1884
+
1885
+ utils.forEach(fns, function transform(fn) {
1886
+ data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
1887
+ });
1888
+
1889
+ headers.normalize();
1890
+
1891
+ return data;
1892
+ }
1893
+
1894
+ function isCancel$1(value) {
1895
+ return !!(value && value.__CANCEL__);
1896
+ }
1897
+
1898
+ /**
1899
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
1900
+ *
1901
+ * @param {string=} message The message.
1902
+ * @param {Object=} config The config.
1903
+ * @param {Object=} request The request.
1904
+ *
1905
+ * @returns {CanceledError} The created error.
1906
+ */
1907
+ function CanceledError$1(message, config, request) {
1908
+ // eslint-disable-next-line no-eq-null,eqeqeq
1909
+ AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
1910
+ this.name = 'CanceledError';
1911
+ }
1912
+
1913
+ utils.inherits(CanceledError$1, AxiosError$1, {
1914
+ __CANCEL__: true
1915
+ });
1916
+
1917
+ /**
1918
+ * Resolve or reject a Promise based on response status.
1919
+ *
1920
+ * @param {Function} resolve A function that resolves the promise.
1921
+ * @param {Function} reject A function that rejects the promise.
1922
+ * @param {object} response The response.
1923
+ *
1924
+ * @returns {object} The response.
1925
+ */
1926
+ function settle(resolve, reject, response) {
1927
+ const validateStatus = response.config.validateStatus;
1928
+ if (!response.status || !validateStatus || validateStatus(response.status)) {
1929
+ resolve(response);
1930
+ } else {
1931
+ reject(new AxiosError$1(
1932
+ 'Request failed with status code ' + response.status,
1933
+ [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
1934
+ response.config,
1935
+ response.request,
1936
+ response
1937
+ ));
1938
+ }
1939
+ }
1940
+
1941
+ const cookies = platform.isStandardBrowserEnv ?
1942
+
1943
+ // Standard browser envs support document.cookie
1944
+ (function standardBrowserEnv() {
1945
+ return {
1946
+ write: function write(name, value, expires, path, domain, secure) {
1947
+ const cookie = [];
1948
+ cookie.push(name + '=' + encodeURIComponent(value));
1949
+
1950
+ if (utils.isNumber(expires)) {
1951
+ cookie.push('expires=' + new Date(expires).toGMTString());
1952
+ }
1953
+
1954
+ if (utils.isString(path)) {
1955
+ cookie.push('path=' + path);
1956
+ }
1957
+
1958
+ if (utils.isString(domain)) {
1959
+ cookie.push('domain=' + domain);
1960
+ }
1961
+
1962
+ if (secure === true) {
1963
+ cookie.push('secure');
1964
+ }
1965
+
1966
+ document.cookie = cookie.join('; ');
1967
+ },
1968
+
1969
+ read: function read(name) {
1970
+ const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1971
+ return (match ? decodeURIComponent(match[3]) : null);
1972
+ },
1973
+
1974
+ remove: function remove(name) {
1975
+ this.write(name, '', Date.now() - 86400000);
1976
+ }
1977
+ };
1978
+ })() :
1979
+
1980
+ // Non standard browser env (web workers, react-native) lack needed support.
1981
+ (function nonStandardBrowserEnv() {
1982
+ return {
1983
+ write: function write() {},
1984
+ read: function read() { return null; },
1985
+ remove: function remove() {}
1986
+ };
1987
+ })();
1988
+
1989
+ /**
1990
+ * Determines whether the specified URL is absolute
1991
+ *
1992
+ * @param {string} url The URL to test
1993
+ *
1994
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
1995
+ */
1996
+ function isAbsoluteURL(url) {
1997
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
1998
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
1999
+ // by any combination of letters, digits, plus, period, or hyphen.
2000
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2001
+ }
2002
+
2003
+ /**
2004
+ * Creates a new URL by combining the specified URLs
2005
+ *
2006
+ * @param {string} baseURL The base URL
2007
+ * @param {string} relativeURL The relative URL
2008
+ *
2009
+ * @returns {string} The combined URL
2010
+ */
2011
+ function combineURLs(baseURL, relativeURL) {
2012
+ return relativeURL
2013
+ ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
2014
+ : baseURL;
2015
+ }
2016
+
2017
+ /**
2018
+ * Creates a new URL by combining the baseURL with the requestedURL,
2019
+ * only when the requestedURL is not already an absolute URL.
2020
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
2021
+ *
2022
+ * @param {string} baseURL The base URL
2023
+ * @param {string} requestedURL Absolute or relative URL to combine
2024
+ *
2025
+ * @returns {string} The combined full path
2026
+ */
2027
+ function buildFullPath(baseURL, requestedURL) {
2028
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
2029
+ return combineURLs(baseURL, requestedURL);
2030
+ }
2031
+ return requestedURL;
2032
+ }
2033
+
2034
+ const isURLSameOrigin = platform.isStandardBrowserEnv ?
2035
+
2036
+ // Standard browser envs have full support of the APIs needed to test
2037
+ // whether the request URL is of the same origin as current location.
2038
+ (function standardBrowserEnv() {
2039
+ const msie = /(msie|trident)/i.test(navigator.userAgent);
2040
+ const urlParsingNode = document.createElement('a');
2041
+ let originURL;
2042
+
2043
+ /**
2044
+ * Parse a URL to discover it's components
2045
+ *
2046
+ * @param {String} url The URL to be parsed
2047
+ * @returns {Object}
2048
+ */
2049
+ function resolveURL(url) {
2050
+ let href = url;
2051
+
2052
+ if (msie) {
2053
+ // IE needs attribute set twice to normalize properties
2054
+ urlParsingNode.setAttribute('href', href);
2055
+ href = urlParsingNode.href;
2056
+ }
1764
2057
 
1765
- function defineAccessor(_header) {
1766
- const lHeader = normalizeHeader(_header);
2058
+ urlParsingNode.setAttribute('href', href);
1767
2059
 
1768
- if (!accessors[lHeader]) {
1769
- buildAccessors(prototype, _header);
1770
- accessors[lHeader] = true;
1771
- }
2060
+ // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
2061
+ return {
2062
+ href: urlParsingNode.href,
2063
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
2064
+ host: urlParsingNode.host,
2065
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
2066
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
2067
+ hostname: urlParsingNode.hostname,
2068
+ port: urlParsingNode.port,
2069
+ pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
2070
+ urlParsingNode.pathname :
2071
+ '/' + urlParsingNode.pathname
2072
+ };
1772
2073
  }
1773
2074
 
1774
- utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
2075
+ originURL = resolveURL(window.location.href);
1775
2076
 
1776
- return this;
1777
- }
1778
- });
2077
+ /**
2078
+ * Determine if a URL shares the same origin as the current location
2079
+ *
2080
+ * @param {String} requestURL The URL to test
2081
+ * @returns {boolean} True if URL shares the same origin, otherwise false
2082
+ */
2083
+ return function isURLSameOrigin(requestURL) {
2084
+ const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
2085
+ return (parsed.protocol === originURL.protocol &&
2086
+ parsed.host === originURL.host);
2087
+ };
2088
+ })() :
1779
2089
 
1780
- AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent']);
2090
+ // Non standard browser envs (web workers, react-native) lack needed support.
2091
+ (function nonStandardBrowserEnv() {
2092
+ return function isURLSameOrigin() {
2093
+ return true;
2094
+ };
2095
+ })();
1781
2096
 
1782
- utils.freezeMethods(AxiosHeaders.prototype);
1783
- utils.freezeMethods(AxiosHeaders);
2097
+ function parseProtocol(url) {
2098
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2099
+ return match && match[1] || '';
2100
+ }
1784
2101
 
1785
2102
  /**
1786
2103
  * Calculate data maxRate
@@ -1830,7 +2147,7 @@ function speedometer(samplesCount, min) {
1830
2147
 
1831
2148
  const passed = startedAt && now - startedAt;
1832
2149
 
1833
- return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2150
+ return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
1834
2151
  };
1835
2152
  }
1836
2153
 
@@ -1853,7 +2170,8 @@ function progressEventReducer(listener, isDownloadStream) {
1853
2170
  progress: total ? (loaded / total) : undefined,
1854
2171
  bytes: progressBytes,
1855
2172
  rate: rate ? rate : undefined,
1856
- estimated: rate && total && inRange ? (total - loaded) / rate : undefined
2173
+ estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
2174
+ event: e
1857
2175
  };
1858
2176
 
1859
2177
  data[isDownloadStream ? 'download' : 'upload'] = true;
@@ -1862,10 +2180,12 @@ function progressEventReducer(listener, isDownloadStream) {
1862
2180
  };
1863
2181
  }
1864
2182
 
1865
- function xhrAdapter(config) {
2183
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
2184
+
2185
+ const xhrAdapter = isXHRAdapterSupported && function (config) {
1866
2186
  return new Promise(function dispatchXhrRequest(resolve, reject) {
1867
2187
  let requestData = config.data;
1868
- const requestHeaders = AxiosHeaders.from(config.headers).normalize();
2188
+ const requestHeaders = AxiosHeaders$2.from(config.headers).normalize();
1869
2189
  const responseType = config.responseType;
1870
2190
  let onCanceled;
1871
2191
  function done() {
@@ -1878,7 +2198,7 @@ function xhrAdapter(config) {
1878
2198
  }
1879
2199
  }
1880
2200
 
1881
- if (utils.isFormData(requestData) && platform.isStandardBrowserEnv) {
2201
+ if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
1882
2202
  requestHeaders.setContentType(false); // Let the browser set it
1883
2203
  }
1884
2204
 
@@ -1903,10 +2223,10 @@ function xhrAdapter(config) {
1903
2223
  return;
1904
2224
  }
1905
2225
  // Prepare the response
1906
- const responseHeaders = AxiosHeaders.from(
2226
+ const responseHeaders = AxiosHeaders$2.from(
1907
2227
  'getAllResponseHeaders' in request && request.getAllResponseHeaders()
1908
2228
  );
1909
- const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
2229
+ const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
1910
2230
  request.responseText : request.response;
1911
2231
  const response = {
1912
2232
  data: responseData,
@@ -1958,7 +2278,7 @@ function xhrAdapter(config) {
1958
2278
  return;
1959
2279
  }
1960
2280
 
1961
- reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
2281
+ reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
1962
2282
 
1963
2283
  // Clean up request
1964
2284
  request = null;
@@ -1968,7 +2288,7 @@ function xhrAdapter(config) {
1968
2288
  request.onerror = function handleError() {
1969
2289
  // Real errors are hidden from us by the browser
1970
2290
  // onerror should only fire if it's a network error
1971
- reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
2291
+ reject(new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request));
1972
2292
 
1973
2293
  // Clean up request
1974
2294
  request = null;
@@ -1981,9 +2301,9 @@ function xhrAdapter(config) {
1981
2301
  if (config.timeoutErrorMessage) {
1982
2302
  timeoutErrorMessage = config.timeoutErrorMessage;
1983
2303
  }
1984
- reject(new AxiosError(
2304
+ reject(new AxiosError$1(
1985
2305
  timeoutErrorMessage,
1986
- transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
2306
+ transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
1987
2307
  config,
1988
2308
  request));
1989
2309
 
@@ -2041,7 +2361,7 @@ function xhrAdapter(config) {
2041
2361
  if (!request) {
2042
2362
  return;
2043
2363
  }
2044
- reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
2364
+ reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
2045
2365
  request.abort();
2046
2366
  request = null;
2047
2367
  };
@@ -2055,7 +2375,7 @@ function xhrAdapter(config) {
2055
2375
  const protocol = parseProtocol(fullPath);
2056
2376
 
2057
2377
  if (protocol && platform.protocols.indexOf(protocol) === -1) {
2058
- reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
2378
+ reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
2059
2379
  return;
2060
2380
  }
2061
2381
 
@@ -2063,238 +2383,63 @@ function xhrAdapter(config) {
2063
2383
  // Send the request
2064
2384
  request.send(requestData || null);
2065
2385
  });
2066
- }
2067
-
2068
- const adapters = {
2069
- http: xhrAdapter,
2070
- xhr: xhrAdapter
2071
2386
  };
2072
2387
 
2073
- const adapters$1 = {
2074
- getAdapter: (nameOrAdapter) => {
2075
- if(utils.isString(nameOrAdapter)){
2076
- const adapter = adapters[nameOrAdapter];
2077
-
2078
- if (!nameOrAdapter) {
2079
- throw Error(
2080
- utils.hasOwnProp(nameOrAdapter) ?
2081
- `Adapter '${nameOrAdapter}' is not available in the build` :
2082
- `Can not resolve adapter '${nameOrAdapter}'`
2083
- );
2084
- }
2085
-
2086
- return adapter
2087
- }
2088
-
2089
- if (!utils.isFunction(nameOrAdapter)) {
2090
- throw new TypeError('adapter is not a function');
2091
- }
2092
-
2093
- return nameOrAdapter;
2094
- },
2095
- adapters
2096
- };
2097
-
2098
- const DEFAULT_CONTENT_TYPE = {
2099
- 'Content-Type': 'application/x-www-form-urlencoded'
2388
+ const knownAdapters = {
2389
+ http: httpAdapter,
2390
+ xhr: xhrAdapter
2100
2391
  };
2101
2392
 
2102
- /**
2103
- * If the browser has an XMLHttpRequest object, use the XHR adapter, otherwise use the HTTP
2104
- * adapter
2105
- *
2106
- * @returns {Function}
2107
- */
2108
- function getDefaultAdapter() {
2109
- let adapter;
2110
- if (typeof XMLHttpRequest !== 'undefined') {
2111
- // For browsers use XHR adapter
2112
- adapter = adapters$1.getAdapter('xhr');
2113
- } else if (typeof process !== 'undefined' && utils.kindOf(process) === 'process') {
2114
- // For node use HTTP adapter
2115
- adapter = adapters$1.getAdapter('http');
2116
- }
2117
- return adapter;
2118
- }
2119
-
2120
- /**
2121
- * It takes a string, tries to parse it, and if it fails, it returns the stringified version
2122
- * of the input
2123
- *
2124
- * @param {any} rawValue - The value to be stringified.
2125
- * @param {Function} parser - A function that parses a string into a JavaScript object.
2126
- * @param {Function} encoder - A function that takes a value and returns a string.
2127
- *
2128
- * @returns {string} A stringified version of the rawValue.
2129
- */
2130
- function stringifySafely(rawValue, parser, encoder) {
2131
- if (utils.isString(rawValue)) {
2393
+ utils.forEach(knownAdapters, (fn, value) => {
2394
+ if(fn) {
2132
2395
  try {
2133
- (parser || JSON.parse)(rawValue);
2134
- return utils.trim(rawValue);
2396
+ Object.defineProperty(fn, 'name', {value});
2135
2397
  } catch (e) {
2136
- if (e.name !== 'SyntaxError') {
2137
- throw e;
2138
- }
2398
+ // eslint-disable-next-line no-empty
2139
2399
  }
2400
+ Object.defineProperty(fn, 'adapterName', {value});
2140
2401
  }
2402
+ });
2141
2403
 
2142
- return (encoder || JSON.stringify)(rawValue);
2143
- }
2144
-
2145
- const defaults = {
2146
-
2147
- transitional: transitionalDefaults,
2148
-
2149
- adapter: getDefaultAdapter(),
2150
-
2151
- transformRequest: [function transformRequest(data, headers) {
2152
- const contentType = headers.getContentType() || '';
2153
- const hasJSONContentType = contentType.indexOf('application/json') > -1;
2154
- const isObjectPayload = utils.isObject(data);
2155
-
2156
- if (isObjectPayload && utils.isHTMLForm(data)) {
2157
- data = new FormData(data);
2158
- }
2404
+ const adapters = {
2405
+ getAdapter: (adapters) => {
2406
+ adapters = utils.isArray(adapters) ? adapters : [adapters];
2159
2407
 
2160
- const isFormData = utils.isFormData(data);
2408
+ const {length} = adapters;
2409
+ let nameOrAdapter;
2410
+ let adapter;
2161
2411
 
2162
- if (isFormData) {
2163
- if (!hasJSONContentType) {
2164
- return data;
2412
+ for (let i = 0; i < length; i++) {
2413
+ nameOrAdapter = adapters[i];
2414
+ if((adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter)) {
2415
+ break;
2165
2416
  }
2166
- return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
2167
- }
2168
-
2169
- if (utils.isArrayBuffer(data) ||
2170
- utils.isBuffer(data) ||
2171
- utils.isStream(data) ||
2172
- utils.isFile(data) ||
2173
- utils.isBlob(data)
2174
- ) {
2175
- return data;
2176
- }
2177
- if (utils.isArrayBufferView(data)) {
2178
- return data.buffer;
2179
- }
2180
- if (utils.isURLSearchParams(data)) {
2181
- headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
2182
- return data.toString();
2183
2417
  }
2184
2418
 
2185
- let isFileList;
2186
-
2187
- if (isObjectPayload) {
2188
- if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
2189
- return toURLEncodedForm(data, this.formSerializer).toString();
2190
- }
2191
-
2192
- if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
2193
- const _FormData = this.env && this.env.FormData;
2194
-
2195
- return toFormData(
2196
- isFileList ? {'files[]': data} : data,
2197
- _FormData && new _FormData(),
2198
- this.formSerializer
2419
+ if (!adapter) {
2420
+ if (adapter === false) {
2421
+ throw new AxiosError$1(
2422
+ `Adapter ${nameOrAdapter} is not supported by the environment`,
2423
+ 'ERR_NOT_SUPPORT'
2199
2424
  );
2200
2425
  }
2201
- }
2202
2426
 
2203
- if (isObjectPayload || hasJSONContentType ) {
2204
- headers.setContentType('application/json', false);
2205
- return stringifySafely(data);
2427
+ throw new Error(
2428
+ utils.hasOwnProp(knownAdapters, nameOrAdapter) ?
2429
+ `Adapter '${nameOrAdapter}' is not available in the build` :
2430
+ `Unknown adapter '${nameOrAdapter}'`
2431
+ );
2206
2432
  }
2207
2433
 
2208
- return data;
2209
- }],
2210
-
2211
- transformResponse: [function transformResponse(data) {
2212
- const transitional = this.transitional || defaults.transitional;
2213
- const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
2214
- const JSONRequested = this.responseType === 'json';
2215
-
2216
- if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
2217
- const silentJSONParsing = transitional && transitional.silentJSONParsing;
2218
- const strictJSONParsing = !silentJSONParsing && JSONRequested;
2219
-
2220
- try {
2221
- return JSON.parse(data);
2222
- } catch (e) {
2223
- if (strictJSONParsing) {
2224
- if (e.name === 'SyntaxError') {
2225
- throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
2226
- }
2227
- throw e;
2228
- }
2229
- }
2434
+ if (!utils.isFunction(adapter)) {
2435
+ throw new TypeError('adapter is not a function');
2230
2436
  }
2231
2437
 
2232
- return data;
2233
- }],
2234
-
2235
- /**
2236
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
2237
- * timeout is not created.
2238
- */
2239
- timeout: 0,
2240
-
2241
- xsrfCookieName: 'XSRF-TOKEN',
2242
- xsrfHeaderName: 'X-XSRF-TOKEN',
2243
-
2244
- maxContentLength: -1,
2245
- maxBodyLength: -1,
2246
-
2247
- env: {
2248
- FormData: platform.classes.FormData,
2249
- Blob: platform.classes.Blob
2250
- },
2251
-
2252
- validateStatus: function validateStatus(status) {
2253
- return status >= 200 && status < 300;
2438
+ return adapter;
2254
2439
  },
2255
-
2256
- headers: {
2257
- common: {
2258
- 'Accept': 'application/json, text/plain, */*'
2259
- }
2260
- }
2440
+ adapters: knownAdapters
2261
2441
  };
2262
2442
 
2263
- utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
2264
- defaults.headers[method] = {};
2265
- });
2266
-
2267
- utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
2268
- defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
2269
- });
2270
-
2271
- /**
2272
- * Transform the data for a request or a response
2273
- *
2274
- * @param {Array|Function} fns A single function or Array of functions
2275
- * @param {?Object} response The response object
2276
- *
2277
- * @returns {*} The resulting transformed data
2278
- */
2279
- function transformData(fns, response) {
2280
- const config = this || defaults;
2281
- const context = response || config;
2282
- const headers = AxiosHeaders.from(context.headers);
2283
- let data = context.data;
2284
-
2285
- utils.forEach(fns, function transform(fn) {
2286
- data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
2287
- });
2288
-
2289
- headers.normalize();
2290
-
2291
- return data;
2292
- }
2293
-
2294
- function isCancel(value) {
2295
- return !!(value && value.__CANCEL__);
2296
- }
2297
-
2298
2443
  /**
2299
2444
  * Throws a `CanceledError` if cancellation has been requested.
2300
2445
  *
@@ -2308,7 +2453,7 @@ function throwIfCancellationRequested(config) {
2308
2453
  }
2309
2454
 
2310
2455
  if (config.signal && config.signal.aborted) {
2311
- throw new CanceledError();
2456
+ throw new CanceledError$1(null, config);
2312
2457
  }
2313
2458
  }
2314
2459
 
@@ -2322,7 +2467,7 @@ function throwIfCancellationRequested(config) {
2322
2467
  function dispatchRequest(config) {
2323
2468
  throwIfCancellationRequested(config);
2324
2469
 
2325
- config.headers = AxiosHeaders.from(config.headers);
2470
+ config.headers = AxiosHeaders$2.from(config.headers);
2326
2471
 
2327
2472
  // Transform request data
2328
2473
  config.data = transformData.call(
@@ -2330,7 +2475,11 @@ function dispatchRequest(config) {
2330
2475
  config.transformRequest
2331
2476
  );
2332
2477
 
2333
- const adapter = config.adapter || defaults.adapter;
2478
+ if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
2479
+ config.headers.setContentType('application/x-www-form-urlencoded', false);
2480
+ }
2481
+
2482
+ const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
2334
2483
 
2335
2484
  return adapter(config).then(function onAdapterResolution(response) {
2336
2485
  throwIfCancellationRequested(config);
@@ -2342,11 +2491,11 @@ function dispatchRequest(config) {
2342
2491
  response
2343
2492
  );
2344
2493
 
2345
- response.headers = AxiosHeaders.from(response.headers);
2494
+ response.headers = AxiosHeaders$2.from(response.headers);
2346
2495
 
2347
2496
  return response;
2348
2497
  }, function onAdapterRejection(reason) {
2349
- if (!isCancel(reason)) {
2498
+ if (!isCancel$1(reason)) {
2350
2499
  throwIfCancellationRequested(config);
2351
2500
 
2352
2501
  // Transform response data
@@ -2356,7 +2505,7 @@ function dispatchRequest(config) {
2356
2505
  config.transformResponse,
2357
2506
  reason.response
2358
2507
  );
2359
- reason.response.headers = AxiosHeaders.from(reason.response.headers);
2508
+ reason.response.headers = AxiosHeaders$2.from(reason.response.headers);
2360
2509
  }
2361
2510
  }
2362
2511
 
@@ -2364,6 +2513,8 @@ function dispatchRequest(config) {
2364
2513
  });
2365
2514
  }
2366
2515
 
2516
+ const headersToObject = (thing) => thing instanceof AxiosHeaders$2 ? thing.toJSON() : thing;
2517
+
2367
2518
  /**
2368
2519
  * Config-specific merge-function which creates a new config-object
2369
2520
  * by merging two configuration objects together.
@@ -2373,14 +2524,14 @@ function dispatchRequest(config) {
2373
2524
  *
2374
2525
  * @returns {Object} New object resulting from merging config2 to config1
2375
2526
  */
2376
- function mergeConfig(config1, config2) {
2527
+ function mergeConfig$1(config1, config2) {
2377
2528
  // eslint-disable-next-line no-param-reassign
2378
2529
  config2 = config2 || {};
2379
2530
  const config = {};
2380
2531
 
2381
- function getMergedValue(target, source) {
2532
+ function getMergedValue(target, source, caseless) {
2382
2533
  if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
2383
- return utils.merge(target, source);
2534
+ return utils.merge.call({caseless}, target, source);
2384
2535
  } else if (utils.isPlainObject(source)) {
2385
2536
  return utils.merge({}, source);
2386
2537
  } else if (utils.isArray(source)) {
@@ -2390,79 +2541,80 @@ function mergeConfig(config1, config2) {
2390
2541
  }
2391
2542
 
2392
2543
  // eslint-disable-next-line consistent-return
2393
- function mergeDeepProperties(prop) {
2394
- if (!utils.isUndefined(config2[prop])) {
2395
- return getMergedValue(config1[prop], config2[prop]);
2396
- } else if (!utils.isUndefined(config1[prop])) {
2397
- return getMergedValue(undefined, config1[prop]);
2544
+ function mergeDeepProperties(a, b, caseless) {
2545
+ if (!utils.isUndefined(b)) {
2546
+ return getMergedValue(a, b, caseless);
2547
+ } else if (!utils.isUndefined(a)) {
2548
+ return getMergedValue(undefined, a, caseless);
2398
2549
  }
2399
2550
  }
2400
2551
 
2401
2552
  // eslint-disable-next-line consistent-return
2402
- function valueFromConfig2(prop) {
2403
- if (!utils.isUndefined(config2[prop])) {
2404
- return getMergedValue(undefined, config2[prop]);
2553
+ function valueFromConfig2(a, b) {
2554
+ if (!utils.isUndefined(b)) {
2555
+ return getMergedValue(undefined, b);
2405
2556
  }
2406
2557
  }
2407
2558
 
2408
2559
  // eslint-disable-next-line consistent-return
2409
- function defaultToConfig2(prop) {
2410
- if (!utils.isUndefined(config2[prop])) {
2411
- return getMergedValue(undefined, config2[prop]);
2412
- } else if (!utils.isUndefined(config1[prop])) {
2413
- return getMergedValue(undefined, config1[prop]);
2560
+ function defaultToConfig2(a, b) {
2561
+ if (!utils.isUndefined(b)) {
2562
+ return getMergedValue(undefined, b);
2563
+ } else if (!utils.isUndefined(a)) {
2564
+ return getMergedValue(undefined, a);
2414
2565
  }
2415
2566
  }
2416
2567
 
2417
2568
  // eslint-disable-next-line consistent-return
2418
- function mergeDirectKeys(prop) {
2569
+ function mergeDirectKeys(a, b, prop) {
2419
2570
  if (prop in config2) {
2420
- return getMergedValue(config1[prop], config2[prop]);
2571
+ return getMergedValue(a, b);
2421
2572
  } else if (prop in config1) {
2422
- return getMergedValue(undefined, config1[prop]);
2573
+ return getMergedValue(undefined, a);
2423
2574
  }
2424
2575
  }
2425
2576
 
2426
2577
  const mergeMap = {
2427
- 'url': valueFromConfig2,
2428
- 'method': valueFromConfig2,
2429
- 'data': valueFromConfig2,
2430
- 'baseURL': defaultToConfig2,
2431
- 'transformRequest': defaultToConfig2,
2432
- 'transformResponse': defaultToConfig2,
2433
- 'paramsSerializer': defaultToConfig2,
2434
- 'timeout': defaultToConfig2,
2435
- 'timeoutMessage': defaultToConfig2,
2436
- 'withCredentials': defaultToConfig2,
2437
- 'adapter': defaultToConfig2,
2438
- 'responseType': defaultToConfig2,
2439
- 'xsrfCookieName': defaultToConfig2,
2440
- 'xsrfHeaderName': defaultToConfig2,
2441
- 'onUploadProgress': defaultToConfig2,
2442
- 'onDownloadProgress': defaultToConfig2,
2443
- 'decompress': defaultToConfig2,
2444
- 'maxContentLength': defaultToConfig2,
2445
- 'maxBodyLength': defaultToConfig2,
2446
- 'beforeRedirect': defaultToConfig2,
2447
- 'transport': defaultToConfig2,
2448
- 'httpAgent': defaultToConfig2,
2449
- 'httpsAgent': defaultToConfig2,
2450
- 'cancelToken': defaultToConfig2,
2451
- 'socketPath': defaultToConfig2,
2452
- 'responseEncoding': defaultToConfig2,
2453
- 'validateStatus': mergeDirectKeys
2578
+ url: valueFromConfig2,
2579
+ method: valueFromConfig2,
2580
+ data: valueFromConfig2,
2581
+ baseURL: defaultToConfig2,
2582
+ transformRequest: defaultToConfig2,
2583
+ transformResponse: defaultToConfig2,
2584
+ paramsSerializer: defaultToConfig2,
2585
+ timeout: defaultToConfig2,
2586
+ timeoutMessage: defaultToConfig2,
2587
+ withCredentials: defaultToConfig2,
2588
+ adapter: defaultToConfig2,
2589
+ responseType: defaultToConfig2,
2590
+ xsrfCookieName: defaultToConfig2,
2591
+ xsrfHeaderName: defaultToConfig2,
2592
+ onUploadProgress: defaultToConfig2,
2593
+ onDownloadProgress: defaultToConfig2,
2594
+ decompress: defaultToConfig2,
2595
+ maxContentLength: defaultToConfig2,
2596
+ maxBodyLength: defaultToConfig2,
2597
+ beforeRedirect: defaultToConfig2,
2598
+ transport: defaultToConfig2,
2599
+ httpAgent: defaultToConfig2,
2600
+ httpsAgent: defaultToConfig2,
2601
+ cancelToken: defaultToConfig2,
2602
+ socketPath: defaultToConfig2,
2603
+ responseEncoding: defaultToConfig2,
2604
+ validateStatus: mergeDirectKeys,
2605
+ headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
2454
2606
  };
2455
2607
 
2456
2608
  utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
2457
2609
  const merge = mergeMap[prop] || mergeDeepProperties;
2458
- const configValue = merge(prop);
2610
+ const configValue = merge(config1[prop], config2[prop], prop);
2459
2611
  (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2460
2612
  });
2461
2613
 
2462
2614
  return config;
2463
2615
  }
2464
2616
 
2465
- const VERSION = "1.1.3";
2617
+ const VERSION$1 = "1.3.3";
2466
2618
 
2467
2619
  const validators$1 = {};
2468
2620
 
@@ -2486,15 +2638,15 @@ const deprecatedWarnings = {};
2486
2638
  */
2487
2639
  validators$1.transitional = function transitional(validator, version, message) {
2488
2640
  function formatMessage(opt, desc) {
2489
- return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
2641
+ return '[Axios v' + VERSION$1 + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
2490
2642
  }
2491
2643
 
2492
2644
  // eslint-disable-next-line func-names
2493
2645
  return (value, opt, opts) => {
2494
2646
  if (validator === false) {
2495
- throw new AxiosError(
2647
+ throw new AxiosError$1(
2496
2648
  formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
2497
- AxiosError.ERR_DEPRECATED
2649
+ AxiosError$1.ERR_DEPRECATED
2498
2650
  );
2499
2651
  }
2500
2652
 
@@ -2525,7 +2677,7 @@ validators$1.transitional = function transitional(validator, version, message) {
2525
2677
 
2526
2678
  function assertOptions(options, schema, allowUnknown) {
2527
2679
  if (typeof options !== 'object') {
2528
- throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
2680
+ throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
2529
2681
  }
2530
2682
  const keys = Object.keys(options);
2531
2683
  let i = keys.length;
@@ -2536,12 +2688,12 @@ function assertOptions(options, schema, allowUnknown) {
2536
2688
  const value = options[opt];
2537
2689
  const result = value === undefined || validator(value, opt, options);
2538
2690
  if (result !== true) {
2539
- throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
2691
+ throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
2540
2692
  }
2541
2693
  continue;
2542
2694
  }
2543
2695
  if (allowUnknown !== true) {
2544
- throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
2696
+ throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
2545
2697
  }
2546
2698
  }
2547
2699
  }
@@ -2560,12 +2712,12 @@ const validators = validator.validators;
2560
2712
  *
2561
2713
  * @return {Axios} A new instance of Axios
2562
2714
  */
2563
- class Axios {
2715
+ class Axios$1 {
2564
2716
  constructor(instanceConfig) {
2565
2717
  this.defaults = instanceConfig;
2566
2718
  this.interceptors = {
2567
- request: new InterceptorManager(),
2568
- response: new InterceptorManager()
2719
+ request: new InterceptorManager$1(),
2720
+ response: new InterceptorManager$1()
2569
2721
  };
2570
2722
  }
2571
2723
 
@@ -2587,9 +2739,9 @@ class Axios {
2587
2739
  config = configOrUrl || {};
2588
2740
  }
2589
2741
 
2590
- config = mergeConfig(this.defaults, config);
2742
+ config = mergeConfig$1(this.defaults, config);
2591
2743
 
2592
- const {transitional, paramsSerializer} = config;
2744
+ const {transitional, paramsSerializer, headers} = config;
2593
2745
 
2594
2746
  if (transitional !== undefined) {
2595
2747
  validator.assertOptions(transitional, {
@@ -2609,20 +2761,22 @@ class Axios {
2609
2761
  // Set config.method
2610
2762
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
2611
2763
 
2764
+ let contextHeaders;
2765
+
2612
2766
  // Flatten headers
2613
- const defaultHeaders = config.headers && utils.merge(
2614
- config.headers.common,
2615
- config.headers[config.method]
2767
+ contextHeaders = headers && utils.merge(
2768
+ headers.common,
2769
+ headers[config.method]
2616
2770
  );
2617
2771
 
2618
- defaultHeaders && utils.forEach(
2772
+ contextHeaders && utils.forEach(
2619
2773
  ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
2620
- function cleanHeaderConfig(method) {
2621
- delete config.headers[method];
2774
+ (method) => {
2775
+ delete headers[method];
2622
2776
  }
2623
2777
  );
2624
2778
 
2625
- config.headers = new AxiosHeaders(config.headers, defaultHeaders);
2779
+ config.headers = AxiosHeaders$2.concat(contextHeaders, headers);
2626
2780
 
2627
2781
  // filter out skipped interceptors
2628
2782
  const requestInterceptorChain = [];
@@ -2695,7 +2849,7 @@ class Axios {
2695
2849
  }
2696
2850
 
2697
2851
  getUri(config) {
2698
- config = mergeConfig(this.defaults, config);
2852
+ config = mergeConfig$1(this.defaults, config);
2699
2853
  const fullPath = buildFullPath(config.baseURL, config.url);
2700
2854
  return buildURL(fullPath, config.params, config.paramsSerializer);
2701
2855
  }
@@ -2704,8 +2858,8 @@ class Axios {
2704
2858
  // Provide aliases for supported request methods
2705
2859
  utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
2706
2860
  /*eslint func-names:0*/
2707
- Axios.prototype[method] = function(url, config) {
2708
- return this.request(mergeConfig(config || {}, {
2861
+ Axios$1.prototype[method] = function(url, config) {
2862
+ return this.request(mergeConfig$1(config || {}, {
2709
2863
  method,
2710
2864
  url,
2711
2865
  data: (config || {}).data
@@ -2718,7 +2872,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
2718
2872
 
2719
2873
  function generateHTTPMethod(isForm) {
2720
2874
  return function httpMethod(url, data, config) {
2721
- return this.request(mergeConfig(config || {}, {
2875
+ return this.request(mergeConfig$1(config || {}, {
2722
2876
  method,
2723
2877
  headers: isForm ? {
2724
2878
  'Content-Type': 'multipart/form-data'
@@ -2729,11 +2883,13 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
2729
2883
  };
2730
2884
  }
2731
2885
 
2732
- Axios.prototype[method] = generateHTTPMethod();
2886
+ Axios$1.prototype[method] = generateHTTPMethod();
2733
2887
 
2734
- Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
2888
+ Axios$1.prototype[method + 'Form'] = generateHTTPMethod(true);
2735
2889
  });
2736
2890
 
2891
+ const Axios$2 = Axios$1;
2892
+
2737
2893
  /**
2738
2894
  * A `CancelToken` is an object that can be used to request cancellation of an operation.
2739
2895
  *
@@ -2741,7 +2897,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
2741
2897
  *
2742
2898
  * @returns {CancelToken}
2743
2899
  */
2744
- class CancelToken {
2900
+ class CancelToken$1 {
2745
2901
  constructor(executor) {
2746
2902
  if (typeof executor !== 'function') {
2747
2903
  throw new TypeError('executor must be a function.');
@@ -2789,7 +2945,7 @@ class CancelToken {
2789
2945
  return;
2790
2946
  }
2791
2947
 
2792
- token.reason = new CanceledError(message, config, request);
2948
+ token.reason = new CanceledError$1(message, config, request);
2793
2949
  resolvePromise(token.reason);
2794
2950
  });
2795
2951
  }
@@ -2840,7 +2996,7 @@ class CancelToken {
2840
2996
  */
2841
2997
  static source() {
2842
2998
  let cancel;
2843
- const token = new CancelToken(function executor(c) {
2999
+ const token = new CancelToken$1(function executor(c) {
2844
3000
  cancel = c;
2845
3001
  });
2846
3002
  return {
@@ -2850,6 +3006,8 @@ class CancelToken {
2850
3006
  }
2851
3007
  }
2852
3008
 
3009
+ const CancelToken$2 = CancelToken$1;
3010
+
2853
3011
  /**
2854
3012
  * Syntactic sugar for invoking a function and expanding an array for arguments.
2855
3013
  *
@@ -2871,7 +3029,7 @@ class CancelToken {
2871
3029
  *
2872
3030
  * @returns {Function}
2873
3031
  */
2874
- function spread(callback) {
3032
+ function spread$1(callback) {
2875
3033
  return function wrap(arr) {
2876
3034
  return callback.apply(null, arr);
2877
3035
  };
@@ -2884,10 +3042,82 @@ function spread(callback) {
2884
3042
  *
2885
3043
  * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
2886
3044
  */
2887
- function isAxiosError(payload) {
3045
+ function isAxiosError$1(payload) {
2888
3046
  return utils.isObject(payload) && (payload.isAxiosError === true);
2889
3047
  }
2890
3048
 
3049
+ const HttpStatusCode$1 = {
3050
+ Continue: 100,
3051
+ SwitchingProtocols: 101,
3052
+ Processing: 102,
3053
+ EarlyHints: 103,
3054
+ Ok: 200,
3055
+ Created: 201,
3056
+ Accepted: 202,
3057
+ NonAuthoritativeInformation: 203,
3058
+ NoContent: 204,
3059
+ ResetContent: 205,
3060
+ PartialContent: 206,
3061
+ MultiStatus: 207,
3062
+ AlreadyReported: 208,
3063
+ ImUsed: 226,
3064
+ MultipleChoices: 300,
3065
+ MovedPermanently: 301,
3066
+ Found: 302,
3067
+ SeeOther: 303,
3068
+ NotModified: 304,
3069
+ UseProxy: 305,
3070
+ Unused: 306,
3071
+ TemporaryRedirect: 307,
3072
+ PermanentRedirect: 308,
3073
+ BadRequest: 400,
3074
+ Unauthorized: 401,
3075
+ PaymentRequired: 402,
3076
+ Forbidden: 403,
3077
+ NotFound: 404,
3078
+ MethodNotAllowed: 405,
3079
+ NotAcceptable: 406,
3080
+ ProxyAuthenticationRequired: 407,
3081
+ RequestTimeout: 408,
3082
+ Conflict: 409,
3083
+ Gone: 410,
3084
+ LengthRequired: 411,
3085
+ PreconditionFailed: 412,
3086
+ PayloadTooLarge: 413,
3087
+ UriTooLong: 414,
3088
+ UnsupportedMediaType: 415,
3089
+ RangeNotSatisfiable: 416,
3090
+ ExpectationFailed: 417,
3091
+ ImATeapot: 418,
3092
+ MisdirectedRequest: 421,
3093
+ UnprocessableEntity: 422,
3094
+ Locked: 423,
3095
+ FailedDependency: 424,
3096
+ TooEarly: 425,
3097
+ UpgradeRequired: 426,
3098
+ PreconditionRequired: 428,
3099
+ TooManyRequests: 429,
3100
+ RequestHeaderFieldsTooLarge: 431,
3101
+ UnavailableForLegalReasons: 451,
3102
+ InternalServerError: 500,
3103
+ NotImplemented: 501,
3104
+ BadGateway: 502,
3105
+ ServiceUnavailable: 503,
3106
+ GatewayTimeout: 504,
3107
+ HttpVersionNotSupported: 505,
3108
+ VariantAlsoNegotiates: 506,
3109
+ InsufficientStorage: 507,
3110
+ LoopDetected: 508,
3111
+ NotExtended: 510,
3112
+ NetworkAuthenticationRequired: 511,
3113
+ };
3114
+
3115
+ Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
3116
+ HttpStatusCode$1[value] = key;
3117
+ });
3118
+
3119
+ const HttpStatusCode$2 = HttpStatusCode$1;
3120
+
2891
3121
  /**
2892
3122
  * Create an instance of Axios
2893
3123
  *
@@ -2896,38 +3126,38 @@ function isAxiosError(payload) {
2896
3126
  * @returns {Axios} A new instance of Axios
2897
3127
  */
2898
3128
  function createInstance(defaultConfig) {
2899
- const context = new Axios(defaultConfig);
2900
- const instance = bind(Axios.prototype.request, context);
3129
+ const context = new Axios$2(defaultConfig);
3130
+ const instance = bind(Axios$2.prototype.request, context);
2901
3131
 
2902
3132
  // Copy axios.prototype to instance
2903
- utils.extend(instance, Axios.prototype, context, {allOwnKeys: true});
3133
+ utils.extend(instance, Axios$2.prototype, context, {allOwnKeys: true});
2904
3134
 
2905
3135
  // Copy context to instance
2906
3136
  utils.extend(instance, context, null, {allOwnKeys: true});
2907
3137
 
2908
3138
  // Factory for creating new instances
2909
3139
  instance.create = function create(instanceConfig) {
2910
- return createInstance(mergeConfig(defaultConfig, instanceConfig));
3140
+ return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
2911
3141
  };
2912
3142
 
2913
3143
  return instance;
2914
3144
  }
2915
3145
 
2916
3146
  // Create the default instance to be exported
2917
- const axios = createInstance(defaults);
3147
+ const axios = createInstance(defaults$1);
2918
3148
 
2919
3149
  // Expose Axios class to allow class inheritance
2920
- axios.Axios = Axios;
3150
+ axios.Axios = Axios$2;
2921
3151
 
2922
3152
  // Expose Cancel & CancelToken
2923
- axios.CanceledError = CanceledError;
2924
- axios.CancelToken = CancelToken;
2925
- axios.isCancel = isCancel;
2926
- axios.VERSION = VERSION;
2927
- axios.toFormData = toFormData;
3153
+ axios.CanceledError = CanceledError$1;
3154
+ axios.CancelToken = CancelToken$2;
3155
+ axios.isCancel = isCancel$1;
3156
+ axios.VERSION = VERSION$1;
3157
+ axios.toFormData = toFormData$1;
2928
3158
 
2929
3159
  // Expose AxiosError class
2930
- axios.AxiosError = AxiosError;
3160
+ axios.AxiosError = AxiosError$1;
2931
3161
 
2932
3162
  // alias for CanceledError for backward compatibility
2933
3163
  axios.Cancel = axios.CanceledError;
@@ -2937,14 +3167,45 @@ axios.all = function all(promises) {
2937
3167
  return Promise.all(promises);
2938
3168
  };
2939
3169
 
2940
- axios.spread = spread;
3170
+ axios.spread = spread$1;
2941
3171
 
2942
3172
  // Expose isAxiosError
2943
- axios.isAxiosError = isAxiosError;
2944
-
2945
- axios.formToJSON = thing => {
2946
- return formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
2947
- };
2948
-
2949
- export { axios as default };
3173
+ axios.isAxiosError = isAxiosError$1;
3174
+
3175
+ // Expose mergeConfig
3176
+ axios.mergeConfig = mergeConfig$1;
3177
+
3178
+ axios.AxiosHeaders = AxiosHeaders$2;
3179
+
3180
+ axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
3181
+
3182
+ axios.HttpStatusCode = HttpStatusCode$2;
3183
+
3184
+ axios.default = axios;
3185
+
3186
+ // this module should only have a default export
3187
+ const axios$1 = axios;
3188
+
3189
+ // This module is intended to unwrap Axios default export as named.
3190
+ // Keep top-level export same with static properties
3191
+ // so that it can keep same with es module or cjs
3192
+ const {
3193
+ Axios,
3194
+ AxiosError,
3195
+ CanceledError,
3196
+ isCancel,
3197
+ CancelToken,
3198
+ VERSION,
3199
+ all,
3200
+ Cancel,
3201
+ isAxiosError,
3202
+ spread,
3203
+ toFormData,
3204
+ AxiosHeaders,
3205
+ HttpStatusCode,
3206
+ formToJSON,
3207
+ mergeConfig
3208
+ } = axios$1;
3209
+
3210
+ export { Axios, AxiosError, AxiosHeaders, Cancel, CancelToken, CanceledError, HttpStatusCode, VERSION, all, axios$1 as default, formToJSON, isAxiosError, isCancel, mergeConfig, spread, toFormData };
2950
3211
  //# sourceMappingURL=axios.js.map