axios 0.19.2 → 0.21.1

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/axios.js CHANGED
@@ -1,4 +1,4 @@
1
- /* axios v0.19.2 | (c) 2020 by Matt Zabriskie */
1
+ /* axios v0.21.1 | (c) 2020 by Matt Zabriskie */
2
2
  (function webpackUniversalModuleDefinition(root, factory) {
3
3
  if(typeof exports === 'object' && typeof module === 'object')
4
4
  module.exports = factory();
@@ -110,6 +110,9 @@ return /******/ (function(modules) { // webpackBootstrap
110
110
  };
111
111
  axios.spread = __webpack_require__(25);
112
112
 
113
+ // Expose isAxiosError
114
+ axios.isAxiosError = __webpack_require__(26);
115
+
113
116
  module.exports = axios;
114
117
 
115
118
  // Allow use of default import syntax in TypeScript
@@ -227,6 +230,21 @@ return /******/ (function(modules) { // webpackBootstrap
227
230
  return val !== null && typeof val === 'object';
228
231
  }
229
232
 
233
+ /**
234
+ * Determine if a value is a plain Object
235
+ *
236
+ * @param {Object} val The value to test
237
+ * @return {boolean} True if value is a plain Object, otherwise false
238
+ */
239
+ function isPlainObject(val) {
240
+ if (toString.call(val) !== '[object Object]') {
241
+ return false;
242
+ }
243
+
244
+ var prototype = Object.getPrototypeOf(val);
245
+ return prototype === null || prototype === Object.prototype;
246
+ }
247
+
230
248
  /**
231
249
  * Determine if a value is a Date
232
250
  *
@@ -383,34 +401,12 @@ return /******/ (function(modules) { // webpackBootstrap
383
401
  function merge(/* obj1, obj2, obj3, ... */) {
384
402
  var result = {};
385
403
  function assignValue(val, key) {
386
- if (typeof result[key] === 'object' && typeof val === 'object') {
404
+ if (isPlainObject(result[key]) && isPlainObject(val)) {
387
405
  result[key] = merge(result[key], val);
388
- } else {
389
- result[key] = val;
390
- }
391
- }
392
-
393
- for (var i = 0, l = arguments.length; i < l; i++) {
394
- forEach(arguments[i], assignValue);
395
- }
396
- return result;
397
- }
398
-
399
- /**
400
- * Function equal to merge with the difference being that no reference
401
- * to original objects is kept.
402
- *
403
- * @see merge
404
- * @param {Object} obj1 Object to merge
405
- * @returns {Object} Result of all merge properties
406
- */
407
- function deepMerge(/* obj1, obj2, obj3, ... */) {
408
- var result = {};
409
- function assignValue(val, key) {
410
- if (typeof result[key] === 'object' && typeof val === 'object') {
411
- result[key] = deepMerge(result[key], val);
412
- } else if (typeof val === 'object') {
413
- result[key] = deepMerge({}, val);
406
+ } else if (isPlainObject(val)) {
407
+ result[key] = merge({}, val);
408
+ } else if (isArray(val)) {
409
+ result[key] = val.slice();
414
410
  } else {
415
411
  result[key] = val;
416
412
  }
@@ -441,6 +437,19 @@ return /******/ (function(modules) { // webpackBootstrap
441
437
  return a;
442
438
  }
443
439
 
440
+ /**
441
+ * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
442
+ *
443
+ * @param {string} content with BOM
444
+ * @return {string} content value without BOM
445
+ */
446
+ function stripBOM(content) {
447
+ if (content.charCodeAt(0) === 0xFEFF) {
448
+ content = content.slice(1);
449
+ }
450
+ return content;
451
+ }
452
+
444
453
  module.exports = {
445
454
  isArray: isArray,
446
455
  isArrayBuffer: isArrayBuffer,
@@ -450,6 +459,7 @@ return /******/ (function(modules) { // webpackBootstrap
450
459
  isString: isString,
451
460
  isNumber: isNumber,
452
461
  isObject: isObject,
462
+ isPlainObject: isPlainObject,
453
463
  isUndefined: isUndefined,
454
464
  isDate: isDate,
455
465
  isFile: isFile,
@@ -460,9 +470,9 @@ return /******/ (function(modules) { // webpackBootstrap
460
470
  isStandardBrowserEnv: isStandardBrowserEnv,
461
471
  forEach: forEach,
462
472
  merge: merge,
463
- deepMerge: deepMerge,
464
473
  extend: extend,
465
- trim: trim
474
+ trim: trim,
475
+ stripBOM: stripBOM
466
476
  };
467
477
 
468
478
 
@@ -562,9 +572,10 @@ return /******/ (function(modules) { // webpackBootstrap
562
572
  utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
563
573
  /*eslint func-names:0*/
564
574
  Axios.prototype[method] = function(url, config) {
565
- return this.request(utils.merge(config || {}, {
575
+ return this.request(mergeConfig(config || {}, {
566
576
  method: method,
567
- url: url
577
+ url: url,
578
+ data: (config || {}).data
568
579
  }));
569
580
  };
570
581
  });
@@ -572,7 +583,7 @@ return /******/ (function(modules) { // webpackBootstrap
572
583
  utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
573
584
  /*eslint func-names:0*/
574
585
  Axios.prototype[method] = function(url, data, config) {
575
- return this.request(utils.merge(config || {}, {
586
+ return this.request(mergeConfig(config || {}, {
576
587
  method: method,
577
588
  url: url,
578
589
  data: data
@@ -593,7 +604,6 @@ return /******/ (function(modules) { // webpackBootstrap
593
604
 
594
605
  function encode(val) {
595
606
  return encodeURIComponent(val).
596
- replace(/%40/gi, '@').
597
607
  replace(/%3A/gi, ':').
598
608
  replace(/%24/g, '$').
599
609
  replace(/%2C/gi, ',').
@@ -920,6 +930,7 @@ return /******/ (function(modules) { // webpackBootstrap
920
930
  xsrfHeaderName: 'X-XSRF-TOKEN',
921
931
 
922
932
  maxContentLength: -1,
933
+ maxBodyLength: -1,
923
934
 
924
935
  validateStatus: function validateStatus(status) {
925
936
  return status >= 200 && status < 300;
@@ -969,10 +980,11 @@ return /******/ (function(modules) { // webpackBootstrap
969
980
 
970
981
  var utils = __webpack_require__(2);
971
982
  var settle = __webpack_require__(13);
983
+ var cookies = __webpack_require__(16);
972
984
  var buildURL = __webpack_require__(5);
973
- var buildFullPath = __webpack_require__(16);
974
- var parseHeaders = __webpack_require__(19);
975
- var isURLSameOrigin = __webpack_require__(20);
985
+ var buildFullPath = __webpack_require__(17);
986
+ var parseHeaders = __webpack_require__(20);
987
+ var isURLSameOrigin = __webpack_require__(21);
976
988
  var createError = __webpack_require__(14);
977
989
 
978
990
  module.exports = function xhrAdapter(config) {
@@ -989,7 +1001,7 @@ return /******/ (function(modules) { // webpackBootstrap
989
1001
  // HTTP basic authentication
990
1002
  if (config.auth) {
991
1003
  var username = config.auth.username || '';
992
- var password = config.auth.password || '';
1004
+ var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
993
1005
  requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
994
1006
  }
995
1007
 
@@ -1070,8 +1082,6 @@ return /******/ (function(modules) { // webpackBootstrap
1070
1082
  // This is only done if running in a standard browser environment.
1071
1083
  // Specifically not if we're in a web worker, or react-native.
1072
1084
  if (utils.isStandardBrowserEnv()) {
1073
- var cookies = __webpack_require__(21);
1074
-
1075
1085
  // Add xsrf header
1076
1086
  var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
1077
1087
  cookies.read(config.xsrfCookieName) :
@@ -1137,7 +1147,7 @@ return /******/ (function(modules) { // webpackBootstrap
1137
1147
  });
1138
1148
  }
1139
1149
 
1140
- if (requestData === undefined) {
1150
+ if (!requestData) {
1141
1151
  requestData = null;
1142
1152
  }
1143
1153
 
@@ -1164,7 +1174,7 @@ return /******/ (function(modules) { // webpackBootstrap
1164
1174
  */
1165
1175
  module.exports = function settle(resolve, reject, response) {
1166
1176
  var validateStatus = response.config.validateStatus;
1167
- if (!validateStatus || validateStatus(response.status)) {
1177
+ if (!response.status || !validateStatus || validateStatus(response.status)) {
1168
1178
  resolve(response);
1169
1179
  } else {
1170
1180
  reject(createError(
@@ -1228,7 +1238,7 @@ return /******/ (function(modules) { // webpackBootstrap
1228
1238
  error.response = response;
1229
1239
  error.isAxiosError = true;
1230
1240
 
1231
- error.toJSON = function() {
1241
+ error.toJSON = function toJSON() {
1232
1242
  return {
1233
1243
  // Standard
1234
1244
  message: this.message,
@@ -1256,8 +1266,67 @@ return /******/ (function(modules) { // webpackBootstrap
1256
1266
 
1257
1267
  'use strict';
1258
1268
 
1259
- var isAbsoluteURL = __webpack_require__(17);
1260
- var combineURLs = __webpack_require__(18);
1269
+ var utils = __webpack_require__(2);
1270
+
1271
+ module.exports = (
1272
+ utils.isStandardBrowserEnv() ?
1273
+
1274
+ // Standard browser envs support document.cookie
1275
+ (function standardBrowserEnv() {
1276
+ return {
1277
+ write: function write(name, value, expires, path, domain, secure) {
1278
+ var cookie = [];
1279
+ cookie.push(name + '=' + encodeURIComponent(value));
1280
+
1281
+ if (utils.isNumber(expires)) {
1282
+ cookie.push('expires=' + new Date(expires).toGMTString());
1283
+ }
1284
+
1285
+ if (utils.isString(path)) {
1286
+ cookie.push('path=' + path);
1287
+ }
1288
+
1289
+ if (utils.isString(domain)) {
1290
+ cookie.push('domain=' + domain);
1291
+ }
1292
+
1293
+ if (secure === true) {
1294
+ cookie.push('secure');
1295
+ }
1296
+
1297
+ document.cookie = cookie.join('; ');
1298
+ },
1299
+
1300
+ read: function read(name) {
1301
+ var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1302
+ return (match ? decodeURIComponent(match[3]) : null);
1303
+ },
1304
+
1305
+ remove: function remove(name) {
1306
+ this.write(name, '', Date.now() - 86400000);
1307
+ }
1308
+ };
1309
+ })() :
1310
+
1311
+ // Non standard browser env (web workers, react-native) lack needed support.
1312
+ (function nonStandardBrowserEnv() {
1313
+ return {
1314
+ write: function write() {},
1315
+ read: function read() { return null; },
1316
+ remove: function remove() {}
1317
+ };
1318
+ })()
1319
+ );
1320
+
1321
+
1322
+ /***/ }),
1323
+ /* 17 */
1324
+ /***/ (function(module, exports, __webpack_require__) {
1325
+
1326
+ 'use strict';
1327
+
1328
+ var isAbsoluteURL = __webpack_require__(18);
1329
+ var combineURLs = __webpack_require__(19);
1261
1330
 
1262
1331
  /**
1263
1332
  * Creates a new URL by combining the baseURL with the requestedURL,
@@ -1277,7 +1346,7 @@ return /******/ (function(modules) { // webpackBootstrap
1277
1346
 
1278
1347
 
1279
1348
  /***/ }),
1280
- /* 17 */
1349
+ /* 18 */
1281
1350
  /***/ (function(module, exports) {
1282
1351
 
1283
1352
  'use strict';
@@ -1297,7 +1366,7 @@ return /******/ (function(modules) { // webpackBootstrap
1297
1366
 
1298
1367
 
1299
1368
  /***/ }),
1300
- /* 18 */
1369
+ /* 19 */
1301
1370
  /***/ (function(module, exports) {
1302
1371
 
1303
1372
  'use strict';
@@ -1317,7 +1386,7 @@ return /******/ (function(modules) { // webpackBootstrap
1317
1386
 
1318
1387
 
1319
1388
  /***/ }),
1320
- /* 19 */
1389
+ /* 20 */
1321
1390
  /***/ (function(module, exports, __webpack_require__) {
1322
1391
 
1323
1392
  'use strict';
@@ -1376,7 +1445,7 @@ return /******/ (function(modules) { // webpackBootstrap
1376
1445
 
1377
1446
 
1378
1447
  /***/ }),
1379
- /* 20 */
1448
+ /* 21 */
1380
1449
  /***/ (function(module, exports, __webpack_require__) {
1381
1450
 
1382
1451
  'use strict';
@@ -1449,65 +1518,6 @@ return /******/ (function(modules) { // webpackBootstrap
1449
1518
  );
1450
1519
 
1451
1520
 
1452
- /***/ }),
1453
- /* 21 */
1454
- /***/ (function(module, exports, __webpack_require__) {
1455
-
1456
- 'use strict';
1457
-
1458
- var utils = __webpack_require__(2);
1459
-
1460
- module.exports = (
1461
- utils.isStandardBrowserEnv() ?
1462
-
1463
- // Standard browser envs support document.cookie
1464
- (function standardBrowserEnv() {
1465
- return {
1466
- write: function write(name, value, expires, path, domain, secure) {
1467
- var cookie = [];
1468
- cookie.push(name + '=' + encodeURIComponent(value));
1469
-
1470
- if (utils.isNumber(expires)) {
1471
- cookie.push('expires=' + new Date(expires).toGMTString());
1472
- }
1473
-
1474
- if (utils.isString(path)) {
1475
- cookie.push('path=' + path);
1476
- }
1477
-
1478
- if (utils.isString(domain)) {
1479
- cookie.push('domain=' + domain);
1480
- }
1481
-
1482
- if (secure === true) {
1483
- cookie.push('secure');
1484
- }
1485
-
1486
- document.cookie = cookie.join('; ');
1487
- },
1488
-
1489
- read: function read(name) {
1490
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1491
- return (match ? decodeURIComponent(match[3]) : null);
1492
- },
1493
-
1494
- remove: function remove(name) {
1495
- this.write(name, '', Date.now() - 86400000);
1496
- }
1497
- };
1498
- })() :
1499
-
1500
- // Non standard browser env (web workers, react-native) lack needed support.
1501
- (function nonStandardBrowserEnv() {
1502
- return {
1503
- write: function write() {},
1504
- read: function read() { return null; },
1505
- remove: function remove() {}
1506
- };
1507
- })()
1508
- );
1509
-
1510
-
1511
1521
  /***/ }),
1512
1522
  /* 22 */
1513
1523
  /***/ (function(module, exports, __webpack_require__) {
@@ -1529,59 +1539,73 @@ return /******/ (function(modules) { // webpackBootstrap
1529
1539
  config2 = config2 || {};
1530
1540
  var config = {};
1531
1541
 
1532
- var valueFromConfig2Keys = ['url', 'method', 'params', 'data'];
1533
- var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy'];
1542
+ var valueFromConfig2Keys = ['url', 'method', 'data'];
1543
+ var mergeDeepPropertiesKeys = ['headers', 'auth', 'proxy', 'params'];
1534
1544
  var defaultToConfig2Keys = [
1535
- 'baseURL', 'url', 'transformRequest', 'transformResponse', 'paramsSerializer',
1536
- 'timeout', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
1537
- 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress',
1538
- 'maxContentLength', 'validateStatus', 'maxRedirects', 'httpAgent',
1539
- 'httpsAgent', 'cancelToken', 'socketPath'
1545
+ 'baseURL', 'transformRequest', 'transformResponse', 'paramsSerializer',
1546
+ 'timeout', 'timeoutMessage', 'withCredentials', 'adapter', 'responseType', 'xsrfCookieName',
1547
+ 'xsrfHeaderName', 'onUploadProgress', 'onDownloadProgress', 'decompress',
1548
+ 'maxContentLength', 'maxBodyLength', 'maxRedirects', 'transport', 'httpAgent',
1549
+ 'httpsAgent', 'cancelToken', 'socketPath', 'responseEncoding'
1540
1550
  ];
1551
+ var directMergeKeys = ['validateStatus'];
1552
+
1553
+ function getMergedValue(target, source) {
1554
+ if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
1555
+ return utils.merge(target, source);
1556
+ } else if (utils.isPlainObject(source)) {
1557
+ return utils.merge({}, source);
1558
+ } else if (utils.isArray(source)) {
1559
+ return source.slice();
1560
+ }
1561
+ return source;
1562
+ }
1563
+
1564
+ function mergeDeepProperties(prop) {
1565
+ if (!utils.isUndefined(config2[prop])) {
1566
+ config[prop] = getMergedValue(config1[prop], config2[prop]);
1567
+ } else if (!utils.isUndefined(config1[prop])) {
1568
+ config[prop] = getMergedValue(undefined, config1[prop]);
1569
+ }
1570
+ }
1541
1571
 
1542
1572
  utils.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
1543
- if (typeof config2[prop] !== 'undefined') {
1544
- config[prop] = config2[prop];
1573
+ if (!utils.isUndefined(config2[prop])) {
1574
+ config[prop] = getMergedValue(undefined, config2[prop]);
1545
1575
  }
1546
1576
  });
1547
1577
 
1548
- utils.forEach(mergeDeepPropertiesKeys, function mergeDeepProperties(prop) {
1549
- if (utils.isObject(config2[prop])) {
1550
- config[prop] = utils.deepMerge(config1[prop], config2[prop]);
1551
- } else if (typeof config2[prop] !== 'undefined') {
1552
- config[prop] = config2[prop];
1553
- } else if (utils.isObject(config1[prop])) {
1554
- config[prop] = utils.deepMerge(config1[prop]);
1555
- } else if (typeof config1[prop] !== 'undefined') {
1556
- config[prop] = config1[prop];
1578
+ utils.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
1579
+
1580
+ utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
1581
+ if (!utils.isUndefined(config2[prop])) {
1582
+ config[prop] = getMergedValue(undefined, config2[prop]);
1583
+ } else if (!utils.isUndefined(config1[prop])) {
1584
+ config[prop] = getMergedValue(undefined, config1[prop]);
1557
1585
  }
1558
1586
  });
1559
1587
 
1560
- utils.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
1561
- if (typeof config2[prop] !== 'undefined') {
1562
- config[prop] = config2[prop];
1563
- } else if (typeof config1[prop] !== 'undefined') {
1564
- config[prop] = config1[prop];
1588
+ utils.forEach(directMergeKeys, function merge(prop) {
1589
+ if (prop in config2) {
1590
+ config[prop] = getMergedValue(config1[prop], config2[prop]);
1591
+ } else if (prop in config1) {
1592
+ config[prop] = getMergedValue(undefined, config1[prop]);
1565
1593
  }
1566
1594
  });
1567
1595
 
1568
1596
  var axiosKeys = valueFromConfig2Keys
1569
1597
  .concat(mergeDeepPropertiesKeys)
1570
- .concat(defaultToConfig2Keys);
1598
+ .concat(defaultToConfig2Keys)
1599
+ .concat(directMergeKeys);
1571
1600
 
1572
1601
  var otherKeys = Object
1573
- .keys(config2)
1602
+ .keys(config1)
1603
+ .concat(Object.keys(config2))
1574
1604
  .filter(function filterAxiosKeys(key) {
1575
1605
  return axiosKeys.indexOf(key) === -1;
1576
1606
  });
1577
1607
 
1578
- utils.forEach(otherKeys, function otherKeysDefaultToConfig2(prop) {
1579
- if (typeof config2[prop] !== 'undefined') {
1580
- config[prop] = config2[prop];
1581
- } else if (typeof config1[prop] !== 'undefined') {
1582
- config[prop] = config1[prop];
1583
- }
1584
- });
1608
+ utils.forEach(otherKeys, mergeDeepProperties);
1585
1609
 
1586
1610
  return config;
1587
1611
  };
@@ -1708,6 +1732,23 @@ return /******/ (function(modules) { // webpackBootstrap
1708
1732
  };
1709
1733
 
1710
1734
 
1735
+ /***/ }),
1736
+ /* 26 */
1737
+ /***/ (function(module, exports) {
1738
+
1739
+ 'use strict';
1740
+
1741
+ /**
1742
+ * Determines whether the payload is an error thrown by Axios
1743
+ *
1744
+ * @param {*} payload The value to test
1745
+ * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
1746
+ */
1747
+ module.exports = function isAxiosError(payload) {
1748
+ return (typeof payload === 'object') && (payload.isAxiosError === true);
1749
+ };
1750
+
1751
+
1711
1752
  /***/ })
1712
1753
  /******/ ])
1713
1754
  });