axios 1.1.3 → 1.2.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.

Potentially problematic release.


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

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.2.0 Copyright (c) 2022 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,24 @@ 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 = typeof self === "undefined" ? typeof global === "undefined" ? undefined : global : self;
284
+
285
+ const isContextDefined = (context) => !isUndefined(context) && context !== _global;
286
+
269
287
  /**
270
288
  * Accepts varargs expecting each argument to be an object, then
271
289
  * immutably merges the properties of each object and returns result.
@@ -285,16 +303,18 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
285
303
  * @returns {Object} Result of all merge properties
286
304
  */
287
305
  function merge(/* obj1, obj2, obj3, ... */) {
306
+ const {caseless} = isContextDefined(this) && this || {};
288
307
  const result = {};
289
308
  const assignValue = (val, key) => {
290
- if (isPlainObject(result[key]) && isPlainObject(val)) {
291
- result[key] = merge(result[key], val);
309
+ const targetKey = caseless && findKey(result, key) || key;
310
+ if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
311
+ result[targetKey] = merge(result[targetKey], val);
292
312
  } else if (isPlainObject(val)) {
293
- result[key] = merge({}, val);
313
+ result[targetKey] = merge({}, val);
294
314
  } else if (isArray(val)) {
295
- result[key] = val.slice();
315
+ result[targetKey] = val.slice();
296
316
  } else {
297
- result[key] = val;
317
+ result[targetKey] = val;
298
318
  }
299
319
  };
300
320
 
@@ -530,6 +550,11 @@ const reduceDescriptors = (obj, reducer) => {
530
550
 
531
551
  const freezeMethods = (obj) => {
532
552
  reduceDescriptors(obj, (descriptor, name) => {
553
+ // skip restricted props in strict mode
554
+ if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
555
+ return false;
556
+ }
557
+
533
558
  const value = obj[name];
534
559
 
535
560
  if (!isFunction(value)) return;
@@ -543,7 +568,7 @@ const freezeMethods = (obj) => {
543
568
 
544
569
  if (!descriptor.set) {
545
570
  descriptor.set = () => {
546
- throw Error('Can not read-only method \'' + name + '\'');
571
+ throw Error('Can not rewrite read-only method \'' + name + '\'');
547
572
  };
548
573
  }
549
574
  });
@@ -570,6 +595,37 @@ const toFiniteNumber = (value, defaultValue) => {
570
595
  return Number.isFinite(value) ? value : defaultValue;
571
596
  };
572
597
 
598
+ const toJSONObject = (obj) => {
599
+ const stack = new Array(10);
600
+
601
+ const visit = (source, i) => {
602
+
603
+ if (isObject(source)) {
604
+ if (stack.indexOf(source) >= 0) {
605
+ return;
606
+ }
607
+
608
+ if(!('toJSON' in source)) {
609
+ stack[i] = source;
610
+ const target = isArray(source) ? [] : {};
611
+
612
+ forEach(source, (value, key) => {
613
+ const reducedValue = visit(value, i + 1);
614
+ !isUndefined(reducedValue) && (target[key] = reducedValue);
615
+ });
616
+
617
+ stack[i] = undefined;
618
+
619
+ return target;
620
+ }
621
+ }
622
+
623
+ return source;
624
+ };
625
+
626
+ return visit(obj, 0);
627
+ };
628
+
573
629
  const utils = {
574
630
  isArray,
575
631
  isArrayBuffer,
@@ -612,7 +668,11 @@ const utils = {
612
668
  toObjectSet,
613
669
  toCamelCase,
614
670
  noop,
615
- toFiniteNumber
671
+ toFiniteNumber,
672
+ findKey,
673
+ global: _global,
674
+ isContextDefined,
675
+ toJSONObject
616
676
  };
617
677
 
618
678
  /**
@@ -626,7 +686,7 @@ const utils = {
626
686
  *
627
687
  * @returns {Error} The created error.
628
688
  */
629
- function AxiosError(message, code, config, request, response) {
689
+ function AxiosError$1(message, code, config, request, response) {
630
690
  Error.call(this);
631
691
 
632
692
  if (Error.captureStackTrace) {
@@ -643,7 +703,7 @@ function AxiosError(message, code, config, request, response) {
643
703
  response && (this.response = response);
644
704
  }
645
705
 
646
- utils.inherits(AxiosError, Error, {
706
+ utils.inherits(AxiosError$1, Error, {
647
707
  toJSON: function toJSON() {
648
708
  return {
649
709
  // Standard
@@ -658,14 +718,14 @@ utils.inherits(AxiosError, Error, {
658
718
  columnNumber: this.columnNumber,
659
719
  stack: this.stack,
660
720
  // Axios
661
- config: this.config,
721
+ config: utils.toJSONObject(this.config),
662
722
  code: this.code,
663
723
  status: this.response && this.response.status ? this.response.status : null
664
724
  };
665
725
  }
666
726
  });
667
727
 
668
- const prototype$1 = AxiosError.prototype;
728
+ const prototype$1 = AxiosError$1.prototype;
669
729
  const descriptors = {};
670
730
 
671
731
  [
@@ -686,11 +746,11 @@ const descriptors = {};
686
746
  descriptors[code] = {value: code};
687
747
  });
688
748
 
689
- Object.defineProperties(AxiosError, descriptors);
749
+ Object.defineProperties(AxiosError$1, descriptors);
690
750
  Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
691
751
 
692
752
  // eslint-disable-next-line func-names
693
- AxiosError.from = (error, code, config, request, response, customProps) => {
753
+ AxiosError$1.from = (error, code, config, request, response, customProps) => {
694
754
  const axiosError = Object.create(prototype$1);
695
755
 
696
756
  utils.toFlatObject(error, axiosError, function filter(obj) {
@@ -699,7 +759,7 @@ AxiosError.from = (error, code, config, request, response, customProps) => {
699
759
  return prop !== 'isAxiosError';
700
760
  });
701
761
 
702
- AxiosError.call(axiosError, error.message, code, config, request, response);
762
+ AxiosError$1.call(axiosError, error.message, code, config, request, response);
703
763
 
704
764
  axiosError.cause = error;
705
765
 
@@ -713,6 +773,8 @@ AxiosError.from = (error, code, config, request, response, customProps) => {
713
773
  /* eslint-env browser */
714
774
  var browser = typeof self == 'object' ? self.FormData : window.FormData;
715
775
 
776
+ const FormData$2 = browser;
777
+
716
778
  /**
717
779
  * Determines if the given thing is a array or js object.
718
780
  *
@@ -802,13 +864,13 @@ function isSpecCompliant(thing) {
802
864
  *
803
865
  * @returns
804
866
  */
805
- function toFormData(obj, formData, options) {
867
+ function toFormData$1(obj, formData, options) {
806
868
  if (!utils.isObject(obj)) {
807
869
  throw new TypeError('target must be an object');
808
870
  }
809
871
 
810
872
  // eslint-disable-next-line no-param-reassign
811
- formData = formData || new (browser || FormData)();
873
+ formData = formData || new (FormData$2 || FormData)();
812
874
 
813
875
  // eslint-disable-next-line no-param-reassign
814
876
  options = utils.toFlatObject(options, {
@@ -840,7 +902,7 @@ function toFormData(obj, formData, options) {
840
902
  }
841
903
 
842
904
  if (!useBlob && utils.isBlob(value)) {
843
- throw new AxiosError('Blob is not supported. Use a Buffer instead.');
905
+ throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
844
906
  }
845
907
 
846
908
  if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
@@ -969,7 +1031,7 @@ function encode$1(str) {
969
1031
  function AxiosURLSearchParams(params, options) {
970
1032
  this._pairs = [];
971
1033
 
972
- params && toFormData(params, this, options);
1034
+ params && toFormData$1(params, this, options);
973
1035
  }
974
1036
 
975
1037
  const prototype = AxiosURLSearchParams.prototype;
@@ -1113,6 +1175,8 @@ class InterceptorManager {
1113
1175
  }
1114
1176
  }
1115
1177
 
1178
+ const InterceptorManager$1 = InterceptorManager;
1179
+
1116
1180
  const transitionalDefaults = {
1117
1181
  silentJSONParsing: true,
1118
1182
  forcedJSONParsing: true,
@@ -1165,7 +1229,7 @@ const platform = {
1165
1229
  };
1166
1230
 
1167
1231
  function toURLEncodedForm(data, options) {
1168
- return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
1232
+ return toFormData$1(data, new platform.classes.URLSearchParams(), Object.assign({
1169
1233
  visitor: function(value, key, path, helpers) {
1170
1234
  if (platform.isNode && utils.isBuffer(value)) {
1171
1235
  this.append(key, value.toString('base64'));
@@ -1264,209 +1328,162 @@ function formDataToJSON(formData) {
1264
1328
  return null;
1265
1329
  }
1266
1330
 
1331
+ const DEFAULT_CONTENT_TYPE = {
1332
+ 'Content-Type': undefined
1333
+ };
1334
+
1267
1335
  /**
1268
- * Resolve or reject a Promise based on response status.
1336
+ * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1337
+ * of the input
1269
1338
  *
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.
1339
+ * @param {any} rawValue - The value to be stringified.
1340
+ * @param {Function} parser - A function that parses a string into a JavaScript object.
1341
+ * @param {Function} encoder - A function that takes a value and returns a string.
1273
1342
  *
1274
- * @returns {object} The response.
1343
+ * @returns {string} A stringified version of the rawValue.
1275
1344
  */
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
- ));
1345
+ function stringifySafely(rawValue, parser, encoder) {
1346
+ if (utils.isString(rawValue)) {
1347
+ try {
1348
+ (parser || JSON.parse)(rawValue);
1349
+ return utils.trim(rawValue);
1350
+ } catch (e) {
1351
+ if (e.name !== 'SyntaxError') {
1352
+ throw e;
1353
+ }
1354
+ }
1288
1355
  }
1289
- }
1290
-
1291
- const cookies = platform.isStandardBrowserEnv ?
1292
1356
 
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));
1357
+ return (encoder || JSON.stringify)(rawValue);
1358
+ }
1299
1359
 
1300
- if (utils.isNumber(expires)) {
1301
- cookie.push('expires=' + new Date(expires).toGMTString());
1302
- }
1360
+ const defaults = {
1303
1361
 
1304
- if (utils.isString(path)) {
1305
- cookie.push('path=' + path);
1306
- }
1362
+ transitional: transitionalDefaults,
1307
1363
 
1308
- if (utils.isString(domain)) {
1309
- cookie.push('domain=' + domain);
1310
- }
1364
+ adapter: ['xhr', 'http'],
1311
1365
 
1312
- if (secure === true) {
1313
- cookie.push('secure');
1314
- }
1366
+ transformRequest: [function transformRequest(data, headers) {
1367
+ const contentType = headers.getContentType() || '';
1368
+ const hasJSONContentType = contentType.indexOf('application/json') > -1;
1369
+ const isObjectPayload = utils.isObject(data);
1315
1370
 
1316
- document.cookie = cookie.join('; ');
1317
- },
1371
+ if (isObjectPayload && utils.isHTMLForm(data)) {
1372
+ data = new FormData(data);
1373
+ }
1318
1374
 
1319
- read: function read(name) {
1320
- const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1321
- return (match ? decodeURIComponent(match[3]) : null);
1322
- },
1375
+ const isFormData = utils.isFormData(data);
1323
1376
 
1324
- remove: function remove(name) {
1325
- this.write(name, '', Date.now() - 86400000);
1377
+ if (isFormData) {
1378
+ if (!hasJSONContentType) {
1379
+ return data;
1326
1380
  }
1327
- };
1328
- })() :
1381
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1382
+ }
1329
1383
 
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
- })();
1384
+ if (utils.isArrayBuffer(data) ||
1385
+ utils.isBuffer(data) ||
1386
+ utils.isStream(data) ||
1387
+ utils.isFile(data) ||
1388
+ utils.isBlob(data)
1389
+ ) {
1390
+ return data;
1391
+ }
1392
+ if (utils.isArrayBufferView(data)) {
1393
+ return data.buffer;
1394
+ }
1395
+ if (utils.isURLSearchParams(data)) {
1396
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1397
+ return data.toString();
1398
+ }
1338
1399
 
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
- }
1400
+ let isFileList;
1352
1401
 
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
- }
1402
+ if (isObjectPayload) {
1403
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
1404
+ return toURLEncodedForm(data, this.formSerializer).toString();
1405
+ }
1366
1406
 
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
- }
1407
+ if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1408
+ const _FormData = this.env && this.env.FormData;
1383
1409
 
1384
- const isURLSameOrigin = platform.isStandardBrowserEnv ?
1410
+ return toFormData$1(
1411
+ isFileList ? {'files[]': data} : data,
1412
+ _FormData && new _FormData(),
1413
+ this.formSerializer
1414
+ );
1415
+ }
1416
+ }
1385
1417
 
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;
1418
+ if (isObjectPayload || hasJSONContentType ) {
1419
+ headers.setContentType('application/json', false);
1420
+ return stringifySafely(data);
1421
+ }
1392
1422
 
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;
1423
+ return data;
1424
+ }],
1401
1425
 
1402
- if (msie) {
1403
- // IE needs attribute set twice to normalize properties
1404
- urlParsingNode.setAttribute('href', href);
1405
- href = urlParsingNode.href;
1406
- }
1426
+ transformResponse: [function transformResponse(data) {
1427
+ const transitional = this.transitional || defaults.transitional;
1428
+ const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1429
+ const JSONRequested = this.responseType === 'json';
1407
1430
 
1408
- urlParsingNode.setAttribute('href', href);
1431
+ if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
1432
+ const silentJSONParsing = transitional && transitional.silentJSONParsing;
1433
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
1409
1434
 
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
- };
1435
+ try {
1436
+ return JSON.parse(data);
1437
+ } catch (e) {
1438
+ if (strictJSONParsing) {
1439
+ if (e.name === 'SyntaxError') {
1440
+ throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
1441
+ }
1442
+ throw e;
1443
+ }
1444
+ }
1423
1445
  }
1424
1446
 
1425
- originURL = resolveURL(window.location.href);
1426
-
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
- })() :
1447
+ return data;
1448
+ }],
1439
1449
 
1440
- // Non standard browser envs (web workers, react-native) lack needed support.
1441
- (function nonStandardBrowserEnv() {
1442
- return function isURLSameOrigin() {
1443
- return true;
1444
- };
1445
- })();
1450
+ /**
1451
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
1452
+ * timeout is not created.
1453
+ */
1454
+ timeout: 0,
1446
1455
 
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
- }
1456
+ xsrfCookieName: 'XSRF-TOKEN',
1457
+ xsrfHeaderName: 'X-XSRF-TOKEN',
1461
1458
 
1462
- utils.inherits(CanceledError, AxiosError, {
1463
- __CANCEL__: true
1459
+ maxContentLength: -1,
1460
+ maxBodyLength: -1,
1461
+
1462
+ env: {
1463
+ FormData: platform.classes.FormData,
1464
+ Blob: platform.classes.Blob
1465
+ },
1466
+
1467
+ validateStatus: function validateStatus(status) {
1468
+ return status >= 200 && status < 300;
1469
+ },
1470
+
1471
+ headers: {
1472
+ common: {
1473
+ 'Accept': 'application/json, text/plain, */*'
1474
+ }
1475
+ }
1476
+ };
1477
+
1478
+ utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
1479
+ defaults.headers[method] = {};
1464
1480
  });
1465
1481
 
1466
- function parseProtocol(url) {
1467
- const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
1468
- return match && match[1] || '';
1469
- }
1482
+ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1483
+ defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
1484
+ });
1485
+
1486
+ const defaults$1 = defaults;
1470
1487
 
1471
1488
  // RawAxiosHeaders whose duplicates are ignored by node
1472
1489
  // c.f. https://nodejs.org/api/http.html#http_message_headers
@@ -1521,7 +1538,6 @@ const parseHeaders = rawHeaders => {
1521
1538
  };
1522
1539
 
1523
1540
  const $internals = Symbol('internals');
1524
- const $defaults = Symbol('defaults');
1525
1541
 
1526
1542
  function normalizeHeader(header) {
1527
1543
  return header && String(header).trim().toLowerCase();
@@ -1547,6 +1563,10 @@ function parseTokens(str) {
1547
1563
  return tokens;
1548
1564
  }
1549
1565
 
1566
+ function isValidHeaderName(str) {
1567
+ return /^[-_a-zA-Z]+$/.test(str.trim());
1568
+ }
1569
+
1550
1570
  function matchHeaderValue(context, value, header, filter) {
1551
1571
  if (utils.isFunction(filter)) {
1552
1572
  return filter.call(this, value, header);
@@ -1583,27 +1603,12 @@ function buildAccessors(obj, header) {
1583
1603
  });
1584
1604
  }
1585
1605
 
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
- }
1606
+ class AxiosHeaders$1 {
1607
+ constructor(headers) {
1608
+ headers && this.set(headers);
1596
1609
  }
1597
- return null;
1598
- }
1599
1610
 
1600
- function AxiosHeaders(headers, defaults) {
1601
- headers && this.set(headers);
1602
- this[$defaults] = defaults || null;
1603
- }
1604
-
1605
- Object.assign(AxiosHeaders.prototype, {
1606
- set: function(header, valueOrRewrite, rewrite) {
1611
+ set(header, valueOrRewrite, rewrite) {
1607
1612
  const self = this;
1608
1613
 
1609
1614
  function setHeader(_value, _header, _rewrite) {
@@ -1613,69 +1618,70 @@ Object.assign(AxiosHeaders.prototype, {
1613
1618
  throw new Error('header name must be a non-empty string');
1614
1619
  }
1615
1620
 
1616
- const key = findKey(self, lHeader);
1621
+ const key = utils.findKey(self, lHeader);
1617
1622
 
1618
- if (key && _rewrite !== true && (self[key] === false || _rewrite === false)) {
1619
- return;
1623
+ if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
1624
+ self[key || _header] = normalizeValue(_value);
1620
1625
  }
1621
-
1622
- self[key || _header] = normalizeValue(_value);
1623
1626
  }
1624
1627
 
1625
- if (utils.isPlainObject(header)) {
1626
- utils.forEach(header, (_value, _header) => {
1627
- setHeader(_value, _header, valueOrRewrite);
1628
- });
1628
+ const setHeaders = (headers, _rewrite) =>
1629
+ utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
1630
+
1631
+ if (utils.isPlainObject(header) || header instanceof this.constructor) {
1632
+ setHeaders(header, valueOrRewrite);
1633
+ } else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1634
+ setHeaders(parseHeaders(header), valueOrRewrite);
1629
1635
  } else {
1630
- setHeader(valueOrRewrite, header, rewrite);
1636
+ header != null && setHeader(valueOrRewrite, header, rewrite);
1631
1637
  }
1632
1638
 
1633
1639
  return this;
1634
- },
1640
+ }
1635
1641
 
1636
- get: function(header, parser) {
1642
+ get(header, parser) {
1637
1643
  header = normalizeHeader(header);
1638
1644
 
1639
- if (!header) return undefined;
1645
+ if (header) {
1646
+ const key = utils.findKey(this, header);
1640
1647
 
1641
- const key = findKey(this, header);
1648
+ if (key) {
1649
+ const value = this[key];
1642
1650
 
1643
- if (key) {
1644
- const value = this[key];
1651
+ if (!parser) {
1652
+ return value;
1653
+ }
1645
1654
 
1646
- if (!parser) {
1647
- return value;
1648
- }
1655
+ if (parser === true) {
1656
+ return parseTokens(value);
1657
+ }
1649
1658
 
1650
- if (parser === true) {
1651
- return parseTokens(value);
1652
- }
1659
+ if (utils.isFunction(parser)) {
1660
+ return parser.call(this, value, key);
1661
+ }
1653
1662
 
1654
- if (utils.isFunction(parser)) {
1655
- return parser.call(this, value, key);
1656
- }
1663
+ if (utils.isRegExp(parser)) {
1664
+ return parser.exec(value);
1665
+ }
1657
1666
 
1658
- if (utils.isRegExp(parser)) {
1659
- return parser.exec(value);
1667
+ throw new TypeError('parser must be boolean|regexp|function');
1660
1668
  }
1661
-
1662
- throw new TypeError('parser must be boolean|regexp|function');
1663
1669
  }
1664
- },
1670
+ }
1665
1671
 
1666
- has: function(header, matcher) {
1672
+ has(header, matcher) {
1667
1673
  header = normalizeHeader(header);
1668
1674
 
1669
1675
  if (header) {
1670
- const key = findKey(this, header);
1676
+ const key = utils.findKey(this, header);
1671
1677
 
1672
1678
  return !!(key && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1673
1679
  }
1674
1680
 
1675
1681
  return false;
1676
- },
1682
+ }
1677
1683
 
1678
- delete: function(header, matcher) {
1684
+ delete(header, matcher) {
1679
1685
  const self = this;
1680
1686
  let deleted = false;
1681
1687
 
@@ -1683,7 +1689,7 @@ Object.assign(AxiosHeaders.prototype, {
1683
1689
  _header = normalizeHeader(_header);
1684
1690
 
1685
1691
  if (_header) {
1686
- const key = findKey(self, _header);
1692
+ const key = utils.findKey(self, _header);
1687
1693
 
1688
1694
  if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
1689
1695
  delete self[key];
@@ -1700,18 +1706,18 @@ Object.assign(AxiosHeaders.prototype, {
1700
1706
  }
1701
1707
 
1702
1708
  return deleted;
1703
- },
1709
+ }
1704
1710
 
1705
- clear: function() {
1711
+ clear() {
1706
1712
  return Object.keys(this).forEach(this.delete.bind(this));
1707
- },
1713
+ }
1708
1714
 
1709
- normalize: function(format) {
1715
+ normalize(format) {
1710
1716
  const self = this;
1711
1717
  const headers = {};
1712
1718
 
1713
1719
  utils.forEach(this, (value, header) => {
1714
- const key = findKey(headers, header);
1720
+ const key = utils.findKey(headers, header);
1715
1721
 
1716
1722
  if (key) {
1717
1723
  self[key] = normalizeValue(value);
@@ -1731,30 +1737,47 @@ Object.assign(AxiosHeaders.prototype, {
1731
1737
  });
1732
1738
 
1733
1739
  return this;
1734
- },
1740
+ }
1735
1741
 
1736
- toJSON: function(asStrings) {
1742
+ concat(...targets) {
1743
+ return this.constructor.concat(this, ...targets);
1744
+ }
1745
+
1746
+ toJSON(asStrings) {
1737
1747
  const obj = Object.create(null);
1738
1748
 
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
- });
1749
+ utils.forEach(this, (value, header) => {
1750
+ value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);
1751
+ });
1744
1752
 
1745
1753
  return obj;
1746
1754
  }
1747
- });
1748
1755
 
1749
- Object.assign(AxiosHeaders, {
1750
- from: function(thing) {
1751
- if (utils.isString(thing)) {
1752
- return new this(parseHeaders(thing));
1753
- }
1756
+ [Symbol.iterator]() {
1757
+ return Object.entries(this.toJSON())[Symbol.iterator]();
1758
+ }
1759
+
1760
+ toString() {
1761
+ return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
1762
+ }
1763
+
1764
+ get [Symbol.toStringTag]() {
1765
+ return 'AxiosHeaders';
1766
+ }
1767
+
1768
+ static from(thing) {
1754
1769
  return thing instanceof this ? thing : new this(thing);
1755
- },
1770
+ }
1756
1771
 
1757
- accessor: function(header) {
1772
+ static concat(first, ...targets) {
1773
+ const computed = new this(first);
1774
+
1775
+ targets.forEach((target) => computed.set(target));
1776
+
1777
+ return computed;
1778
+ }
1779
+
1780
+ static accessor(header) {
1758
1781
  const internals = this[$internals] = (this[$internals] = {
1759
1782
  accessors: {}
1760
1783
  });
@@ -1762,25 +1785,261 @@ Object.assign(AxiosHeaders, {
1762
1785
  const accessors = internals.accessors;
1763
1786
  const prototype = this.prototype;
1764
1787
 
1765
- function defineAccessor(_header) {
1766
- const lHeader = normalizeHeader(_header);
1788
+ function defineAccessor(_header) {
1789
+ const lHeader = normalizeHeader(_header);
1790
+
1791
+ if (!accessors[lHeader]) {
1792
+ buildAccessors(prototype, _header);
1793
+ accessors[lHeader] = true;
1794
+ }
1795
+ }
1796
+
1797
+ utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1798
+
1799
+ return this;
1800
+ }
1801
+ }
1802
+
1803
+ AxiosHeaders$1.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent']);
1804
+
1805
+ utils.freezeMethods(AxiosHeaders$1.prototype);
1806
+ utils.freezeMethods(AxiosHeaders$1);
1807
+
1808
+ const AxiosHeaders$2 = AxiosHeaders$1;
1809
+
1810
+ /**
1811
+ * Transform the data for a request or a response
1812
+ *
1813
+ * @param {Array|Function} fns A single function or Array of functions
1814
+ * @param {?Object} response The response object
1815
+ *
1816
+ * @returns {*} The resulting transformed data
1817
+ */
1818
+ function transformData(fns, response) {
1819
+ const config = this || defaults$1;
1820
+ const context = response || config;
1821
+ const headers = AxiosHeaders$2.from(context.headers);
1822
+ let data = context.data;
1823
+
1824
+ utils.forEach(fns, function transform(fn) {
1825
+ data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
1826
+ });
1827
+
1828
+ headers.normalize();
1829
+
1830
+ return data;
1831
+ }
1832
+
1833
+ function isCancel$1(value) {
1834
+ return !!(value && value.__CANCEL__);
1835
+ }
1836
+
1837
+ /**
1838
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
1839
+ *
1840
+ * @param {string=} message The message.
1841
+ * @param {Object=} config The config.
1842
+ * @param {Object=} request The request.
1843
+ *
1844
+ * @returns {CanceledError} The created error.
1845
+ */
1846
+ function CanceledError$1(message, config, request) {
1847
+ // eslint-disable-next-line no-eq-null,eqeqeq
1848
+ AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
1849
+ this.name = 'CanceledError';
1850
+ }
1851
+
1852
+ utils.inherits(CanceledError$1, AxiosError$1, {
1853
+ __CANCEL__: true
1854
+ });
1855
+
1856
+ // eslint-disable-next-line strict
1857
+ const httpAdapter = null;
1858
+
1859
+ /**
1860
+ * Resolve or reject a Promise based on response status.
1861
+ *
1862
+ * @param {Function} resolve A function that resolves the promise.
1863
+ * @param {Function} reject A function that rejects the promise.
1864
+ * @param {object} response The response.
1865
+ *
1866
+ * @returns {object} The response.
1867
+ */
1868
+ function settle(resolve, reject, response) {
1869
+ const validateStatus = response.config.validateStatus;
1870
+ if (!response.status || !validateStatus || validateStatus(response.status)) {
1871
+ resolve(response);
1872
+ } else {
1873
+ reject(new AxiosError$1(
1874
+ 'Request failed with status code ' + response.status,
1875
+ [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
1876
+ response.config,
1877
+ response.request,
1878
+ response
1879
+ ));
1880
+ }
1881
+ }
1882
+
1883
+ const cookies = platform.isStandardBrowserEnv ?
1884
+
1885
+ // Standard browser envs support document.cookie
1886
+ (function standardBrowserEnv() {
1887
+ return {
1888
+ write: function write(name, value, expires, path, domain, secure) {
1889
+ const cookie = [];
1890
+ cookie.push(name + '=' + encodeURIComponent(value));
1891
+
1892
+ if (utils.isNumber(expires)) {
1893
+ cookie.push('expires=' + new Date(expires).toGMTString());
1894
+ }
1895
+
1896
+ if (utils.isString(path)) {
1897
+ cookie.push('path=' + path);
1898
+ }
1899
+
1900
+ if (utils.isString(domain)) {
1901
+ cookie.push('domain=' + domain);
1902
+ }
1903
+
1904
+ if (secure === true) {
1905
+ cookie.push('secure');
1906
+ }
1907
+
1908
+ document.cookie = cookie.join('; ');
1909
+ },
1910
+
1911
+ read: function read(name) {
1912
+ const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1913
+ return (match ? decodeURIComponent(match[3]) : null);
1914
+ },
1915
+
1916
+ remove: function remove(name) {
1917
+ this.write(name, '', Date.now() - 86400000);
1918
+ }
1919
+ };
1920
+ })() :
1921
+
1922
+ // Non standard browser env (web workers, react-native) lack needed support.
1923
+ (function nonStandardBrowserEnv() {
1924
+ return {
1925
+ write: function write() {},
1926
+ read: function read() { return null; },
1927
+ remove: function remove() {}
1928
+ };
1929
+ })();
1930
+
1931
+ /**
1932
+ * Determines whether the specified URL is absolute
1933
+ *
1934
+ * @param {string} url The URL to test
1935
+ *
1936
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
1937
+ */
1938
+ function isAbsoluteURL(url) {
1939
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
1940
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
1941
+ // by any combination of letters, digits, plus, period, or hyphen.
1942
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
1943
+ }
1944
+
1945
+ /**
1946
+ * Creates a new URL by combining the specified URLs
1947
+ *
1948
+ * @param {string} baseURL The base URL
1949
+ * @param {string} relativeURL The relative URL
1950
+ *
1951
+ * @returns {string} The combined URL
1952
+ */
1953
+ function combineURLs(baseURL, relativeURL) {
1954
+ return relativeURL
1955
+ ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
1956
+ : baseURL;
1957
+ }
1958
+
1959
+ /**
1960
+ * Creates a new URL by combining the baseURL with the requestedURL,
1961
+ * only when the requestedURL is not already an absolute URL.
1962
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
1963
+ *
1964
+ * @param {string} baseURL The base URL
1965
+ * @param {string} requestedURL Absolute or relative URL to combine
1966
+ *
1967
+ * @returns {string} The combined full path
1968
+ */
1969
+ function buildFullPath(baseURL, requestedURL) {
1970
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
1971
+ return combineURLs(baseURL, requestedURL);
1972
+ }
1973
+ return requestedURL;
1974
+ }
1975
+
1976
+ const isURLSameOrigin = platform.isStandardBrowserEnv ?
1977
+
1978
+ // Standard browser envs have full support of the APIs needed to test
1979
+ // whether the request URL is of the same origin as current location.
1980
+ (function standardBrowserEnv() {
1981
+ const msie = /(msie|trident)/i.test(navigator.userAgent);
1982
+ const urlParsingNode = document.createElement('a');
1983
+ let originURL;
1984
+
1985
+ /**
1986
+ * Parse a URL to discover it's components
1987
+ *
1988
+ * @param {String} url The URL to be parsed
1989
+ * @returns {Object}
1990
+ */
1991
+ function resolveURL(url) {
1992
+ let href = url;
1767
1993
 
1768
- if (!accessors[lHeader]) {
1769
- buildAccessors(prototype, _header);
1770
- accessors[lHeader] = true;
1994
+ if (msie) {
1995
+ // IE needs attribute set twice to normalize properties
1996
+ urlParsingNode.setAttribute('href', href);
1997
+ href = urlParsingNode.href;
1771
1998
  }
1999
+
2000
+ urlParsingNode.setAttribute('href', href);
2001
+
2002
+ // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
2003
+ return {
2004
+ href: urlParsingNode.href,
2005
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
2006
+ host: urlParsingNode.host,
2007
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
2008
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
2009
+ hostname: urlParsingNode.hostname,
2010
+ port: urlParsingNode.port,
2011
+ pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
2012
+ urlParsingNode.pathname :
2013
+ '/' + urlParsingNode.pathname
2014
+ };
1772
2015
  }
1773
2016
 
1774
- utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
2017
+ originURL = resolveURL(window.location.href);
1775
2018
 
1776
- return this;
1777
- }
1778
- });
2019
+ /**
2020
+ * Determine if a URL shares the same origin as the current location
2021
+ *
2022
+ * @param {String} requestURL The URL to test
2023
+ * @returns {boolean} True if URL shares the same origin, otherwise false
2024
+ */
2025
+ return function isURLSameOrigin(requestURL) {
2026
+ const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
2027
+ return (parsed.protocol === originURL.protocol &&
2028
+ parsed.host === originURL.host);
2029
+ };
2030
+ })() :
1779
2031
 
1780
- AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent']);
2032
+ // Non standard browser envs (web workers, react-native) lack needed support.
2033
+ (function nonStandardBrowserEnv() {
2034
+ return function isURLSameOrigin() {
2035
+ return true;
2036
+ };
2037
+ })();
1781
2038
 
1782
- utils.freezeMethods(AxiosHeaders.prototype);
1783
- utils.freezeMethods(AxiosHeaders);
2039
+ function parseProtocol(url) {
2040
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2041
+ return match && match[1] || '';
2042
+ }
1784
2043
 
1785
2044
  /**
1786
2045
  * Calculate data maxRate
@@ -1853,7 +2112,8 @@ function progressEventReducer(listener, isDownloadStream) {
1853
2112
  progress: total ? (loaded / total) : undefined,
1854
2113
  bytes: progressBytes,
1855
2114
  rate: rate ? rate : undefined,
1856
- estimated: rate && total && inRange ? (total - loaded) / rate : undefined
2115
+ estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
2116
+ event: e
1857
2117
  };
1858
2118
 
1859
2119
  data[isDownloadStream ? 'download' : 'upload'] = true;
@@ -1862,10 +2122,12 @@ function progressEventReducer(listener, isDownloadStream) {
1862
2122
  };
1863
2123
  }
1864
2124
 
1865
- function xhrAdapter(config) {
2125
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
2126
+
2127
+ const xhrAdapter = isXHRAdapterSupported && function (config) {
1866
2128
  return new Promise(function dispatchXhrRequest(resolve, reject) {
1867
2129
  let requestData = config.data;
1868
- const requestHeaders = AxiosHeaders.from(config.headers).normalize();
2130
+ const requestHeaders = AxiosHeaders$2.from(config.headers).normalize();
1869
2131
  const responseType = config.responseType;
1870
2132
  let onCanceled;
1871
2133
  function done() {
@@ -1903,7 +2165,7 @@ function xhrAdapter(config) {
1903
2165
  return;
1904
2166
  }
1905
2167
  // Prepare the response
1906
- const responseHeaders = AxiosHeaders.from(
2168
+ const responseHeaders = AxiosHeaders$2.from(
1907
2169
  'getAllResponseHeaders' in request && request.getAllResponseHeaders()
1908
2170
  );
1909
2171
  const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
@@ -1958,7 +2220,7 @@ function xhrAdapter(config) {
1958
2220
  return;
1959
2221
  }
1960
2222
 
1961
- reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
2223
+ reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
1962
2224
 
1963
2225
  // Clean up request
1964
2226
  request = null;
@@ -1968,7 +2230,7 @@ function xhrAdapter(config) {
1968
2230
  request.onerror = function handleError() {
1969
2231
  // Real errors are hidden from us by the browser
1970
2232
  // onerror should only fire if it's a network error
1971
- reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
2233
+ reject(new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request));
1972
2234
 
1973
2235
  // Clean up request
1974
2236
  request = null;
@@ -1981,9 +2243,9 @@ function xhrAdapter(config) {
1981
2243
  if (config.timeoutErrorMessage) {
1982
2244
  timeoutErrorMessage = config.timeoutErrorMessage;
1983
2245
  }
1984
- reject(new AxiosError(
2246
+ reject(new AxiosError$1(
1985
2247
  timeoutErrorMessage,
1986
- transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
2248
+ transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
1987
2249
  config,
1988
2250
  request));
1989
2251
 
@@ -2041,7 +2303,7 @@ function xhrAdapter(config) {
2041
2303
  if (!request) {
2042
2304
  return;
2043
2305
  }
2044
- reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
2306
+ reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
2045
2307
  request.abort();
2046
2308
  request = null;
2047
2309
  };
@@ -2055,7 +2317,7 @@ function xhrAdapter(config) {
2055
2317
  const protocol = parseProtocol(fullPath);
2056
2318
 
2057
2319
  if (protocol && platform.protocols.indexOf(protocol) === -1) {
2058
- reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
2320
+ reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
2059
2321
  return;
2060
2322
  }
2061
2323
 
@@ -2063,238 +2325,63 @@ function xhrAdapter(config) {
2063
2325
  // Send the request
2064
2326
  request.send(requestData || null);
2065
2327
  });
2066
- }
2067
-
2068
- const adapters = {
2069
- http: xhrAdapter,
2070
- xhr: xhrAdapter
2071
- };
2072
-
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
2328
  };
2097
2329
 
2098
- const DEFAULT_CONTENT_TYPE = {
2099
- 'Content-Type': 'application/x-www-form-urlencoded'
2330
+ const knownAdapters = {
2331
+ http: httpAdapter,
2332
+ xhr: xhrAdapter
2100
2333
  };
2101
2334
 
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)) {
2335
+ utils.forEach(knownAdapters, (fn, value) => {
2336
+ if(fn) {
2132
2337
  try {
2133
- (parser || JSON.parse)(rawValue);
2134
- return utils.trim(rawValue);
2338
+ Object.defineProperty(fn, 'name', {value});
2135
2339
  } catch (e) {
2136
- if (e.name !== 'SyntaxError') {
2137
- throw e;
2138
- }
2340
+ // eslint-disable-next-line no-empty
2139
2341
  }
2342
+ Object.defineProperty(fn, 'adapterName', {value});
2140
2343
  }
2344
+ });
2141
2345
 
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
- }
2346
+ const adapters = {
2347
+ getAdapter: (adapters) => {
2348
+ adapters = utils.isArray(adapters) ? adapters : [adapters];
2159
2349
 
2160
- const isFormData = utils.isFormData(data);
2350
+ const {length} = adapters;
2351
+ let nameOrAdapter;
2352
+ let adapter;
2161
2353
 
2162
- if (isFormData) {
2163
- if (!hasJSONContentType) {
2164
- return data;
2354
+ for (let i = 0; i < length; i++) {
2355
+ nameOrAdapter = adapters[i];
2356
+ if((adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter)) {
2357
+ break;
2165
2358
  }
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
2359
  }
2184
2360
 
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
2361
+ if (!adapter) {
2362
+ if (adapter === false) {
2363
+ throw new AxiosError$1(
2364
+ `Adapter ${nameOrAdapter} is not supported by the environment`,
2365
+ 'ERR_NOT_SUPPORT'
2199
2366
  );
2200
2367
  }
2201
- }
2202
2368
 
2203
- if (isObjectPayload || hasJSONContentType ) {
2204
- headers.setContentType('application/json', false);
2205
- return stringifySafely(data);
2369
+ throw new Error(
2370
+ utils.hasOwnProp(knownAdapters, nameOrAdapter) ?
2371
+ `Adapter '${nameOrAdapter}' is not available in the build` :
2372
+ `Unknown adapter '${nameOrAdapter}'`
2373
+ );
2206
2374
  }
2207
2375
 
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
- }
2376
+ if (!utils.isFunction(adapter)) {
2377
+ throw new TypeError('adapter is not a function');
2230
2378
  }
2231
2379
 
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;
2380
+ return adapter;
2254
2381
  },
2255
-
2256
- headers: {
2257
- common: {
2258
- 'Accept': 'application/json, text/plain, */*'
2259
- }
2260
- }
2382
+ adapters: knownAdapters
2261
2383
  };
2262
2384
 
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
2385
  /**
2299
2386
  * Throws a `CanceledError` if cancellation has been requested.
2300
2387
  *
@@ -2308,7 +2395,7 @@ function throwIfCancellationRequested(config) {
2308
2395
  }
2309
2396
 
2310
2397
  if (config.signal && config.signal.aborted) {
2311
- throw new CanceledError();
2398
+ throw new CanceledError$1();
2312
2399
  }
2313
2400
  }
2314
2401
 
@@ -2322,7 +2409,7 @@ function throwIfCancellationRequested(config) {
2322
2409
  function dispatchRequest(config) {
2323
2410
  throwIfCancellationRequested(config);
2324
2411
 
2325
- config.headers = AxiosHeaders.from(config.headers);
2412
+ config.headers = AxiosHeaders$2.from(config.headers);
2326
2413
 
2327
2414
  // Transform request data
2328
2415
  config.data = transformData.call(
@@ -2330,7 +2417,11 @@ function dispatchRequest(config) {
2330
2417
  config.transformRequest
2331
2418
  );
2332
2419
 
2333
- const adapter = config.adapter || defaults.adapter;
2420
+ if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
2421
+ config.headers.setContentType('application/x-www-form-urlencoded', false);
2422
+ }
2423
+
2424
+ const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
2334
2425
 
2335
2426
  return adapter(config).then(function onAdapterResolution(response) {
2336
2427
  throwIfCancellationRequested(config);
@@ -2342,11 +2433,11 @@ function dispatchRequest(config) {
2342
2433
  response
2343
2434
  );
2344
2435
 
2345
- response.headers = AxiosHeaders.from(response.headers);
2436
+ response.headers = AxiosHeaders$2.from(response.headers);
2346
2437
 
2347
2438
  return response;
2348
2439
  }, function onAdapterRejection(reason) {
2349
- if (!isCancel(reason)) {
2440
+ if (!isCancel$1(reason)) {
2350
2441
  throwIfCancellationRequested(config);
2351
2442
 
2352
2443
  // Transform response data
@@ -2356,7 +2447,7 @@ function dispatchRequest(config) {
2356
2447
  config.transformResponse,
2357
2448
  reason.response
2358
2449
  );
2359
- reason.response.headers = AxiosHeaders.from(reason.response.headers);
2450
+ reason.response.headers = AxiosHeaders$2.from(reason.response.headers);
2360
2451
  }
2361
2452
  }
2362
2453
 
@@ -2364,6 +2455,8 @@ function dispatchRequest(config) {
2364
2455
  });
2365
2456
  }
2366
2457
 
2458
+ const headersToObject = (thing) => thing instanceof AxiosHeaders$2 ? thing.toJSON() : thing;
2459
+
2367
2460
  /**
2368
2461
  * Config-specific merge-function which creates a new config-object
2369
2462
  * by merging two configuration objects together.
@@ -2378,9 +2471,9 @@ function mergeConfig(config1, config2) {
2378
2471
  config2 = config2 || {};
2379
2472
  const config = {};
2380
2473
 
2381
- function getMergedValue(target, source) {
2474
+ function getMergedValue(target, source, caseless) {
2382
2475
  if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
2383
- return utils.merge(target, source);
2476
+ return utils.merge.call({caseless}, target, source);
2384
2477
  } else if (utils.isPlainObject(source)) {
2385
2478
  return utils.merge({}, source);
2386
2479
  } else if (utils.isArray(source)) {
@@ -2390,79 +2483,80 @@ function mergeConfig(config1, config2) {
2390
2483
  }
2391
2484
 
2392
2485
  // 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]);
2486
+ function mergeDeepProperties(a, b, caseless) {
2487
+ if (!utils.isUndefined(b)) {
2488
+ return getMergedValue(a, b, caseless);
2489
+ } else if (!utils.isUndefined(a)) {
2490
+ return getMergedValue(undefined, a, caseless);
2398
2491
  }
2399
2492
  }
2400
2493
 
2401
2494
  // eslint-disable-next-line consistent-return
2402
- function valueFromConfig2(prop) {
2403
- if (!utils.isUndefined(config2[prop])) {
2404
- return getMergedValue(undefined, config2[prop]);
2495
+ function valueFromConfig2(a, b) {
2496
+ if (!utils.isUndefined(b)) {
2497
+ return getMergedValue(undefined, b);
2405
2498
  }
2406
2499
  }
2407
2500
 
2408
2501
  // 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]);
2502
+ function defaultToConfig2(a, b) {
2503
+ if (!utils.isUndefined(b)) {
2504
+ return getMergedValue(undefined, b);
2505
+ } else if (!utils.isUndefined(a)) {
2506
+ return getMergedValue(undefined, a);
2414
2507
  }
2415
2508
  }
2416
2509
 
2417
2510
  // eslint-disable-next-line consistent-return
2418
- function mergeDirectKeys(prop) {
2511
+ function mergeDirectKeys(a, b, prop) {
2419
2512
  if (prop in config2) {
2420
- return getMergedValue(config1[prop], config2[prop]);
2513
+ return getMergedValue(a, b);
2421
2514
  } else if (prop in config1) {
2422
- return getMergedValue(undefined, config1[prop]);
2515
+ return getMergedValue(undefined, a);
2423
2516
  }
2424
2517
  }
2425
2518
 
2426
2519
  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
2520
+ url: valueFromConfig2,
2521
+ method: valueFromConfig2,
2522
+ data: valueFromConfig2,
2523
+ baseURL: defaultToConfig2,
2524
+ transformRequest: defaultToConfig2,
2525
+ transformResponse: defaultToConfig2,
2526
+ paramsSerializer: defaultToConfig2,
2527
+ timeout: defaultToConfig2,
2528
+ timeoutMessage: defaultToConfig2,
2529
+ withCredentials: defaultToConfig2,
2530
+ adapter: defaultToConfig2,
2531
+ responseType: defaultToConfig2,
2532
+ xsrfCookieName: defaultToConfig2,
2533
+ xsrfHeaderName: defaultToConfig2,
2534
+ onUploadProgress: defaultToConfig2,
2535
+ onDownloadProgress: defaultToConfig2,
2536
+ decompress: defaultToConfig2,
2537
+ maxContentLength: defaultToConfig2,
2538
+ maxBodyLength: defaultToConfig2,
2539
+ beforeRedirect: defaultToConfig2,
2540
+ transport: defaultToConfig2,
2541
+ httpAgent: defaultToConfig2,
2542
+ httpsAgent: defaultToConfig2,
2543
+ cancelToken: defaultToConfig2,
2544
+ socketPath: defaultToConfig2,
2545
+ responseEncoding: defaultToConfig2,
2546
+ validateStatus: mergeDirectKeys,
2547
+ headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
2454
2548
  };
2455
2549
 
2456
2550
  utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
2457
2551
  const merge = mergeMap[prop] || mergeDeepProperties;
2458
- const configValue = merge(prop);
2552
+ const configValue = merge(config1[prop], config2[prop], prop);
2459
2553
  (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2460
2554
  });
2461
2555
 
2462
2556
  return config;
2463
2557
  }
2464
2558
 
2465
- const VERSION = "1.1.3";
2559
+ const VERSION$1 = "1.2.0";
2466
2560
 
2467
2561
  const validators$1 = {};
2468
2562
 
@@ -2486,15 +2580,15 @@ const deprecatedWarnings = {};
2486
2580
  */
2487
2581
  validators$1.transitional = function transitional(validator, version, message) {
2488
2582
  function formatMessage(opt, desc) {
2489
- return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
2583
+ return '[Axios v' + VERSION$1 + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
2490
2584
  }
2491
2585
 
2492
2586
  // eslint-disable-next-line func-names
2493
2587
  return (value, opt, opts) => {
2494
2588
  if (validator === false) {
2495
- throw new AxiosError(
2589
+ throw new AxiosError$1(
2496
2590
  formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
2497
- AxiosError.ERR_DEPRECATED
2591
+ AxiosError$1.ERR_DEPRECATED
2498
2592
  );
2499
2593
  }
2500
2594
 
@@ -2525,7 +2619,7 @@ validators$1.transitional = function transitional(validator, version, message) {
2525
2619
 
2526
2620
  function assertOptions(options, schema, allowUnknown) {
2527
2621
  if (typeof options !== 'object') {
2528
- throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
2622
+ throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
2529
2623
  }
2530
2624
  const keys = Object.keys(options);
2531
2625
  let i = keys.length;
@@ -2536,12 +2630,12 @@ function assertOptions(options, schema, allowUnknown) {
2536
2630
  const value = options[opt];
2537
2631
  const result = value === undefined || validator(value, opt, options);
2538
2632
  if (result !== true) {
2539
- throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
2633
+ throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
2540
2634
  }
2541
2635
  continue;
2542
2636
  }
2543
2637
  if (allowUnknown !== true) {
2544
- throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
2638
+ throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
2545
2639
  }
2546
2640
  }
2547
2641
  }
@@ -2560,12 +2654,12 @@ const validators = validator.validators;
2560
2654
  *
2561
2655
  * @return {Axios} A new instance of Axios
2562
2656
  */
2563
- class Axios {
2657
+ class Axios$1 {
2564
2658
  constructor(instanceConfig) {
2565
2659
  this.defaults = instanceConfig;
2566
2660
  this.interceptors = {
2567
- request: new InterceptorManager(),
2568
- response: new InterceptorManager()
2661
+ request: new InterceptorManager$1(),
2662
+ response: new InterceptorManager$1()
2569
2663
  };
2570
2664
  }
2571
2665
 
@@ -2589,7 +2683,7 @@ class Axios {
2589
2683
 
2590
2684
  config = mergeConfig(this.defaults, config);
2591
2685
 
2592
- const {transitional, paramsSerializer} = config;
2686
+ const {transitional, paramsSerializer, headers} = config;
2593
2687
 
2594
2688
  if (transitional !== undefined) {
2595
2689
  validator.assertOptions(transitional, {
@@ -2609,20 +2703,22 @@ class Axios {
2609
2703
  // Set config.method
2610
2704
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
2611
2705
 
2706
+ let contextHeaders;
2707
+
2612
2708
  // Flatten headers
2613
- const defaultHeaders = config.headers && utils.merge(
2614
- config.headers.common,
2615
- config.headers[config.method]
2709
+ contextHeaders = headers && utils.merge(
2710
+ headers.common,
2711
+ headers[config.method]
2616
2712
  );
2617
2713
 
2618
- defaultHeaders && utils.forEach(
2714
+ contextHeaders && utils.forEach(
2619
2715
  ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
2620
- function cleanHeaderConfig(method) {
2621
- delete config.headers[method];
2716
+ (method) => {
2717
+ delete headers[method];
2622
2718
  }
2623
2719
  );
2624
2720
 
2625
- config.headers = new AxiosHeaders(config.headers, defaultHeaders);
2721
+ config.headers = AxiosHeaders$2.concat(contextHeaders, headers);
2626
2722
 
2627
2723
  // filter out skipped interceptors
2628
2724
  const requestInterceptorChain = [];
@@ -2704,7 +2800,7 @@ class Axios {
2704
2800
  // Provide aliases for supported request methods
2705
2801
  utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
2706
2802
  /*eslint func-names:0*/
2707
- Axios.prototype[method] = function(url, config) {
2803
+ Axios$1.prototype[method] = function(url, config) {
2708
2804
  return this.request(mergeConfig(config || {}, {
2709
2805
  method,
2710
2806
  url,
@@ -2729,11 +2825,13 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
2729
2825
  };
2730
2826
  }
2731
2827
 
2732
- Axios.prototype[method] = generateHTTPMethod();
2828
+ Axios$1.prototype[method] = generateHTTPMethod();
2733
2829
 
2734
- Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
2830
+ Axios$1.prototype[method + 'Form'] = generateHTTPMethod(true);
2735
2831
  });
2736
2832
 
2833
+ const Axios$2 = Axios$1;
2834
+
2737
2835
  /**
2738
2836
  * A `CancelToken` is an object that can be used to request cancellation of an operation.
2739
2837
  *
@@ -2741,7 +2839,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
2741
2839
  *
2742
2840
  * @returns {CancelToken}
2743
2841
  */
2744
- class CancelToken {
2842
+ class CancelToken$1 {
2745
2843
  constructor(executor) {
2746
2844
  if (typeof executor !== 'function') {
2747
2845
  throw new TypeError('executor must be a function.');
@@ -2789,7 +2887,7 @@ class CancelToken {
2789
2887
  return;
2790
2888
  }
2791
2889
 
2792
- token.reason = new CanceledError(message, config, request);
2890
+ token.reason = new CanceledError$1(message, config, request);
2793
2891
  resolvePromise(token.reason);
2794
2892
  });
2795
2893
  }
@@ -2840,7 +2938,7 @@ class CancelToken {
2840
2938
  */
2841
2939
  static source() {
2842
2940
  let cancel;
2843
- const token = new CancelToken(function executor(c) {
2941
+ const token = new CancelToken$1(function executor(c) {
2844
2942
  cancel = c;
2845
2943
  });
2846
2944
  return {
@@ -2850,6 +2948,8 @@ class CancelToken {
2850
2948
  }
2851
2949
  }
2852
2950
 
2951
+ const CancelToken$2 = CancelToken$1;
2952
+
2853
2953
  /**
2854
2954
  * Syntactic sugar for invoking a function and expanding an array for arguments.
2855
2955
  *
@@ -2871,7 +2971,7 @@ class CancelToken {
2871
2971
  *
2872
2972
  * @returns {Function}
2873
2973
  */
2874
- function spread(callback) {
2974
+ function spread$1(callback) {
2875
2975
  return function wrap(arr) {
2876
2976
  return callback.apply(null, arr);
2877
2977
  };
@@ -2884,7 +2984,7 @@ function spread(callback) {
2884
2984
  *
2885
2985
  * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
2886
2986
  */
2887
- function isAxiosError(payload) {
2987
+ function isAxiosError$1(payload) {
2888
2988
  return utils.isObject(payload) && (payload.isAxiosError === true);
2889
2989
  }
2890
2990
 
@@ -2896,11 +2996,11 @@ function isAxiosError(payload) {
2896
2996
  * @returns {Axios} A new instance of Axios
2897
2997
  */
2898
2998
  function createInstance(defaultConfig) {
2899
- const context = new Axios(defaultConfig);
2900
- const instance = bind(Axios.prototype.request, context);
2999
+ const context = new Axios$2(defaultConfig);
3000
+ const instance = bind(Axios$2.prototype.request, context);
2901
3001
 
2902
3002
  // Copy axios.prototype to instance
2903
- utils.extend(instance, Axios.prototype, context, {allOwnKeys: true});
3003
+ utils.extend(instance, Axios$2.prototype, context, {allOwnKeys: true});
2904
3004
 
2905
3005
  // Copy context to instance
2906
3006
  utils.extend(instance, context, null, {allOwnKeys: true});
@@ -2914,20 +3014,20 @@ function createInstance(defaultConfig) {
2914
3014
  }
2915
3015
 
2916
3016
  // Create the default instance to be exported
2917
- const axios = createInstance(defaults);
3017
+ const axios = createInstance(defaults$1);
2918
3018
 
2919
3019
  // Expose Axios class to allow class inheritance
2920
- axios.Axios = Axios;
3020
+ axios.Axios = Axios$2;
2921
3021
 
2922
3022
  // Expose Cancel & CancelToken
2923
- axios.CanceledError = CanceledError;
2924
- axios.CancelToken = CancelToken;
2925
- axios.isCancel = isCancel;
2926
- axios.VERSION = VERSION;
2927
- axios.toFormData = toFormData;
3023
+ axios.CanceledError = CanceledError$1;
3024
+ axios.CancelToken = CancelToken$2;
3025
+ axios.isCancel = isCancel$1;
3026
+ axios.VERSION = VERSION$1;
3027
+ axios.toFormData = toFormData$1;
2928
3028
 
2929
3029
  // Expose AxiosError class
2930
- axios.AxiosError = AxiosError;
3030
+ axios.AxiosError = AxiosError$1;
2931
3031
 
2932
3032
  // alias for CanceledError for backward compatibility
2933
3033
  axios.Cancel = axios.CanceledError;
@@ -2937,14 +3037,38 @@ axios.all = function all(promises) {
2937
3037
  return Promise.all(promises);
2938
3038
  };
2939
3039
 
2940
- axios.spread = spread;
3040
+ axios.spread = spread$1;
2941
3041
 
2942
3042
  // 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 };
3043
+ axios.isAxiosError = isAxiosError$1;
3044
+
3045
+ axios.AxiosHeaders = AxiosHeaders$2;
3046
+
3047
+ axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
3048
+
3049
+ axios.default = axios;
3050
+
3051
+ // this module should only have a default export
3052
+ const axios$1 = axios;
3053
+
3054
+ // This module is intended to unwrap Axios default export as named.
3055
+ // Keep top-level export same with static properties
3056
+ // so that it can keep same with es module or cjs
3057
+ const {
3058
+ Axios,
3059
+ AxiosError,
3060
+ CanceledError,
3061
+ isCancel,
3062
+ CancelToken,
3063
+ VERSION,
3064
+ all,
3065
+ Cancel,
3066
+ isAxiosError,
3067
+ spread,
3068
+ toFormData,
3069
+ AxiosHeaders,
3070
+ formToJSON
3071
+ } = axios$1;
3072
+
3073
+ export { Axios, AxiosError, AxiosHeaders, Cancel, CancelToken, CanceledError, VERSION, all, axios$1 as default, formToJSON, isAxiosError, isCancel, spread, toFormData };
2950
3074
  //# sourceMappingURL=axios.js.map