axios 0.31.1 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/axios.js CHANGED
@@ -1,4 +1,4 @@
1
- // axios v0.31.1 Copyright (c) 2026 Matt Zabriskie
1
+ // axios v0.33.0 Copyright (c) 2026 Matt Zabriskie
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -58,8 +58,14 @@
58
58
  * @returns {boolean} True if value is a Buffer, otherwise false
59
59
  */
60
60
  function isBuffer(val) {
61
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
62
- && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
61
+ return (
62
+ val !== null &&
63
+ !isUndefined(val) &&
64
+ val.constructor !== null &&
65
+ !isUndefined(val.constructor) &&
66
+ typeof val.constructor.isBuffer === 'function' &&
67
+ val.constructor.isBuffer(val)
68
+ );
63
69
  }
64
70
 
65
71
  /**
@@ -71,7 +77,6 @@
71
77
  */
72
78
  var isArrayBuffer = kindOfTest('ArrayBuffer');
73
79
 
74
-
75
80
  /**
76
81
  * Determine if a value is a view on an ArrayBuffer
77
82
  *
@@ -80,10 +85,10 @@
80
85
  */
81
86
  function isArrayBufferView(val) {
82
87
  var result;
83
- if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
88
+ if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
84
89
  result = ArrayBuffer.isView(val);
85
90
  } else {
86
- result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
91
+ result = val && val.buffer && isArrayBuffer(val.buffer);
87
92
  }
88
93
  return result;
89
94
  }
@@ -220,12 +225,14 @@
220
225
  // Reject non-objects (strings, numbers, booleans) up front — Object.getPrototypeOf
221
226
  // throws a TypeError on primitives in ES5 environments.
222
227
  if (!isObject(thing)) return false;
223
- // Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData (GHSA-6chq-wfr3-2hj9).
228
+ // Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData.
224
229
  var proto = Object.getPrototypeOf(thing);
225
230
  if (!proto || proto === Object.prototype) return false;
226
231
  if (!isFunction(thing.append)) return false;
227
- return toString.call(thing) === pattern ||
228
- (isFunction(thing.toString) && thing.toString() === pattern);
232
+ return (
233
+ toString.call(thing) === pattern ||
234
+ (isFunction(thing.toString) && thing.toString() === pattern)
235
+ );
229
236
  }
230
237
 
231
238
  /**
@@ -243,7 +250,9 @@
243
250
  * @returns {String} The String freed of excess whitespace
244
251
  */
245
252
  function trim(str) {
246
- return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
253
+ return str.trim
254
+ ? str.trim()
255
+ : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
247
256
  }
248
257
 
249
258
  /**
@@ -263,10 +272,11 @@
263
272
  */
264
273
  function isStandardBrowserEnv() {
265
274
  var product;
266
- if (typeof navigator !== 'undefined' && (
267
- (product = navigator.product) === 'ReactNative' ||
268
- product === 'NativeScript' ||
269
- product === 'NS')
275
+ if (
276
+ typeof navigator !== 'undefined' &&
277
+ ((product = navigator.product) === 'ReactNative' ||
278
+ product === 'NativeScript' ||
279
+ product === 'NS')
270
280
  ) {
271
281
  return false;
272
282
  }
@@ -331,14 +341,20 @@
331
341
  * @returns {Object} Result of all merge properties
332
342
  */
333
343
  function merge(/* obj1, obj2, obj3, ... */) {
334
- var result = {};
344
+ var result = Object.create(null);
335
345
  function assignValue(val, key) {
346
+ var target;
347
+
336
348
  if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
337
349
  return;
338
350
  }
339
351
 
340
- if (isPlainObject(result[key]) && isPlainObject(val)) {
341
- result[key] = merge(result[key], val);
352
+ target = Object.prototype.hasOwnProperty.call(result, key)
353
+ ? result[key]
354
+ : undefined;
355
+
356
+ if (isPlainObject(target) && isPlainObject(val)) {
357
+ result[key] = merge(target, val);
342
358
  } else if (isPlainObject(val)) {
343
359
  result[key] = merge({}, val);
344
360
  } else if (isArray(val)) {
@@ -380,7 +396,7 @@
380
396
  * @return {string} content value without BOM
381
397
  */
382
398
  function stripBOM(content) {
383
- if (content.charCodeAt(0) === 0xFEFF) {
399
+ if (content.charCodeAt(0) === 0xfeff) {
384
400
  content = content.slice(1);
385
401
  }
386
402
  return content;
@@ -395,7 +411,10 @@
395
411
  */
396
412
 
397
413
  function inherits(constructor, superConstructor, props, descriptors) {
398
- constructor.prototype = Object.create(superConstructor.prototype, descriptors);
414
+ constructor.prototype = Object.create(
415
+ superConstructor.prototype,
416
+ descriptors
417
+ );
399
418
  constructor.prototype.constructor = constructor;
400
419
  props && Object.assign(constructor.prototype, props);
401
420
  }
@@ -424,13 +443,20 @@
424
443
  i = props.length;
425
444
  while (i-- > 0) {
426
445
  prop = props[i];
427
- if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
446
+ if (
447
+ (!propFilter || propFilter(prop, sourceObj, destObj)) &&
448
+ !merged[prop]
449
+ ) {
428
450
  destObj[prop] = sourceObj[prop];
429
451
  merged[prop] = true;
430
452
  }
431
453
  }
432
454
  sourceObj = filter !== false && Object.getPrototypeOf(sourceObj);
433
- } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
455
+ } while (
456
+ sourceObj &&
457
+ (!filter || filter(sourceObj, destObj)) &&
458
+ sourceObj !== Object.prototype
459
+ );
434
460
 
435
461
  return destObj;
436
462
  }
@@ -452,7 +478,6 @@
452
478
  return lastIndex !== -1 && lastIndex === position;
453
479
  }
454
480
 
455
-
456
481
  /**
457
482
  * Returns new array from array like object or null if failed
458
483
  * @param {*} [thing]
@@ -548,6 +573,82 @@
548
573
  hasOwnProperty: hasOwnProperty
549
574
  };
550
575
 
576
+ var defaultRedactKeys = ['authorization', 'proxy-authorization', 'cookie', 'set-cookie', 'x-api-key', 'password'];
577
+
578
+ var REDACTED_VALUE = '[REDACTED ****]';
579
+
580
+ function makeValueDescriptor(value) {
581
+ var descriptor = Object.create(null);
582
+ descriptor.value = value;
583
+ return descriptor;
584
+ }
585
+
586
+ function getRedactKeys(config) {
587
+ // An empty array is treated as "no override" so an upstream `redact: []` cannot
588
+ // silently disable redaction. To opt out, pass non-string values or unset keys.
589
+ var override = config && utils.isArray(config.redact) && config.redact.length ? config.redact : null;
590
+ var redact = override || defaultRedactKeys;
591
+ var keys = {};
592
+
593
+ utils.forEach(redact, function eachRedactKey(key) {
594
+ if (typeof key === 'string') {
595
+ keys[key.toLowerCase()] = true;
596
+ }
597
+ });
598
+
599
+ return keys;
600
+ }
601
+
602
+ function shouldRedact(key, keys) {
603
+ return typeof key === 'string' && keys[key.toLowerCase()];
604
+ }
605
+
606
+ var CIRCULAR_VALUE = '[Circular]';
607
+
608
+ function serializeConfigValue(value, keys, key, seen) {
609
+ var result;
610
+
611
+ if (shouldRedact(key, keys)) {
612
+ return REDACTED_VALUE;
613
+ }
614
+
615
+ if (utils.isArray(value)) {
616
+ if (seen.indexOf(value) !== -1) {
617
+ return CIRCULAR_VALUE;
618
+ }
619
+ seen.push(value);
620
+ result = [];
621
+ utils.forEach(value, function eachArrayValue(item, index) {
622
+ result[index] = serializeConfigValue(item, keys, index, seen);
623
+ });
624
+ seen.pop();
625
+ return result;
626
+ }
627
+
628
+ if (utils.isPlainObject(value)) {
629
+ if (seen.indexOf(value) !== -1) {
630
+ return CIRCULAR_VALUE;
631
+ }
632
+ seen.push(value);
633
+ result = {};
634
+ utils.forEach(value, function eachObjectValue(item, itemKey) {
635
+ result[itemKey] = serializeConfigValue(item, keys, itemKey, seen);
636
+ });
637
+ seen.pop();
638
+ return result;
639
+ }
640
+
641
+ return value;
642
+ }
643
+
644
+ function serializeConfig(config) {
645
+ if (!config) {
646
+ return config;
647
+ }
648
+
649
+ return serializeConfigValue(config, getRedactKeys(config), undefined, []);
650
+ }
651
+
551
652
  /**
552
653
  * Create an Error with the specified message, config, error code, request and response.
553
654
  *
@@ -590,7 +691,7 @@
590
691
  columnNumber: this.columnNumber,
591
692
  stack: this.stack,
592
693
  // Axios
593
- config: this.config,
694
+ config: serializeConfig(this.config),
594
695
  code: this.code,
595
696
  status: this.response && this.response.status ? this.response.status : null
596
697
  };
@@ -598,7 +699,7 @@
598
699
  });
599
700
 
600
701
  var prototype$1 = AxiosError.prototype;
601
- var descriptors = {};
702
+ var descriptors = Object.create(null);
602
703
 
603
704
  [
604
705
  'ERR_BAD_OPTION_VALUE',
@@ -616,11 +717,11 @@
616
717
  'ERR_FORM_DATA_DEPTH_EXCEEDED'
617
718
  // eslint-disable-next-line func-names
618
719
  ].forEach(function(code) {
619
- descriptors[code] = {value: code};
720
+ descriptors[code] = makeValueDescriptor(code);
620
721
  });
621
722
 
622
723
  Object.defineProperties(AxiosError, descriptors);
623
- Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
724
+ Object.defineProperty(prototype$1, 'isAxiosError', makeValueDescriptor(true));
624
725
 
625
726
  // eslint-disable-next-line func-names
626
727
  AxiosError.from = function(error, code, config, request, response, customProps) {
@@ -739,6 +840,29 @@
739
840
  return value;
740
841
  }
741
842
 
843
+ var stack = [];
844
+
845
+ function assertValueDepth(value, depth) {
846
+ if (depth > maxDepth) {
847
+ throw new AxiosError_1(
848
+ 'Maximum object depth of ' + maxDepth + ' exceeded (got ' + depth + ' levels)',
849
+ AxiosError_1.ERR_FORM_DATA_DEPTH_EXCEEDED
850
+ );
851
+ }
852
+
853
+ if (!utils.isObject(value) || stack.indexOf(value) !== -1) {
854
+ return;
855
+ }
856
+
857
+ stack.push(value);
858
+
859
+ utils.forEach(value, function each(el) {
860
+ assertValueDepth(el, depth + 1);
861
+ });
862
+
863
+ stack.pop();
864
+ }
865
+
742
866
  /**
743
867
  *
744
868
  * @param {*} value
@@ -754,6 +878,7 @@
754
878
  if (utils.endsWith(key, '{}')) {
755
879
  // eslint-disable-next-line no-param-reassign
756
880
  key = metaTokens ? key : key.slice(0, -2);
881
+ assertValueDepth(value, 1);
757
882
  // eslint-disable-next-line no-param-reassign
758
883
  value = JSON.stringify(value);
759
884
  } else if (
@@ -783,8 +908,6 @@
783
908
  return false;
784
909
  }
785
910
 
786
- var stack = [];
787
-
788
911
  var exposedHelpers = Object.assign(predicates, {
789
912
  defaultVisitor: defaultVisitor,
790
913
  convertValue: convertValue,
@@ -835,7 +958,7 @@
835
958
  var toFormData_1 = toFormData;
836
959
 
837
960
  function encode$1(str) {
838
- // Do not map `%00` back to a raw null byte (GHSA-xhjh-pmcv-23jw): that reversed
961
+ // Do not map `%00` back to a raw null byte: that reversed
839
962
  // the safe percent-encoding from encodeURIComponent and enabled null byte injection.
840
963
  var charMap = {
841
964
  '!': '%21',
@@ -845,9 +968,12 @@
845
968
  '~': '%7E',
846
969
  '%20': '+'
847
970
  };
848
- return encodeURIComponent(str).replace(/[!'\(\)~]|%20/g, function replacer(match) {
849
- return charMap[match];
850
- });
971
+ return encodeURIComponent(str).replace(
972
+ /[!'\(\)~]|%20/g,
973
+ function replacer(match) {
974
+ return charMap[match];
975
+ }
976
+ );
851
977
  }
852
978
 
853
979
  function AxiosURLSearchParams(params, options) {
@@ -863,13 +989,17 @@
863
989
  };
864
990
 
865
991
  prototype.toString = function toString(encoder) {
866
- var _encode = encoder ? function(value) {
867
- return encoder.call(this, value, encode$1);
868
- } : encode$1;
992
+ var _encode = encoder
993
+ ? function(value) {
994
+ return encoder.call(this, value, encode$1);
995
+ }
996
+ : encode$1;
869
997
 
870
- return this._pairs.map(function each(pair) {
871
- return _encode(pair[0]) + '=' + _encode(pair[1]);
872
- }, '').join('&');
998
+ return this._pairs
999
+ .map(function each(pair) {
1000
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
1001
+ }, '')
1002
+ .join('&');
873
1003
  };
874
1004
 
875
1005
  var AxiosURLSearchParams_1 = AxiosURLSearchParams;
@@ -904,9 +1034,17 @@
904
1034
  url = url.slice(0, hashmarkIndex);
905
1035
  }
906
1036
 
907
- var _encode = options && options.encode || encode;
1037
+ var _encode = encode;
1038
+ var serializeFn;
908
1039
 
909
- var serializeFn = options && options.serialize;
1040
+ if (options) {
1041
+ if (utils.isFunction(options)) {
1042
+ serializeFn = options;
1043
+ } else {
1044
+ _encode = utils.hasOwnProperty(options, 'encode') && options.encode || encode;
1045
+ serializeFn = utils.hasOwnProperty(options, 'serialize') ? options.serialize : undefined;
1046
+ }
1047
+ }
910
1048
 
911
1049
  var serializedParams;
912
1050
 
@@ -1029,6 +1167,19 @@
1029
1167
  }, options));
1030
1168
  };
1031
1169
 
1170
+ var MAX_FORM_DATA_TO_JSON_DEPTH = 100;
1171
+
1172
+ function assertPathDepth(path) {
1173
+ var depth = path.length - 1;
1174
+
1175
+ if (depth > MAX_FORM_DATA_TO_JSON_DEPTH) {
1176
+ throw new AxiosError_1(
1177
+ 'Maximum object depth of ' + MAX_FORM_DATA_TO_JSON_DEPTH + ' exceeded (got ' + depth + ' levels)',
1178
+ AxiosError_1.ERR_FORM_DATA_DEPTH_EXCEEDED
1179
+ );
1180
+ }
1181
+ }
1182
+
1032
1183
  function parsePropPath(name) {
1033
1184
  // foo[x][y][z]
1034
1185
  // foo.x.y.z
@@ -1089,7 +1240,10 @@
1089
1240
  var obj = {};
1090
1241
 
1091
1242
  utils.forEachEntry(formData, function(name, value) {
1092
- buildPath(parsePropPath(name), value, obj, 0);
1243
+ var path = parsePropPath(name);
1244
+
1245
+ assertPathDepth(path);
1246
+ buildPath(path, value, obj, 0);
1093
1247
  });
1094
1248
 
1095
1249
  return obj;
@@ -1152,8 +1306,21 @@
1152
1306
  },
1153
1307
 
1154
1308
  read: function read(name) {
1155
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1156
- return (match ? decodeURIComponent(match[3]) : null);
1309
+ var nameEQ = name + '=';
1310
+ var cookies = document.cookie.split(';');
1311
+ var cookie;
1312
+
1313
+ for (var i = 0; i < cookies.length; i++) {
1314
+ cookie = cookies[i];
1315
+ while (cookie.charAt(0) === ' ') {
1316
+ cookie = cookie.substring(1);
1317
+ }
1318
+ if (cookie.indexOf(nameEQ) === 0) {
1319
+ return decodeURIComponent(cookie.substring(nameEQ.length));
1320
+ }
1321
+ }
1322
+
1323
+ return null;
1157
1324
  },
1158
1325
 
1159
1326
  remove: function remove(name) {
@@ -1362,8 +1529,10 @@
1362
1529
  var requestData = config.data;
1363
1530
  var requestHeaders = config.headers;
1364
1531
  var responseType = config.responseType;
1365
- // Guard against prototype pollution (GHSA-xx6v-rp6x-q39c): only honor own properties.
1366
- var withXSRFToken = utils.hasOwnProperty(config, 'withXSRFToken') ? config.withXSRFToken : undefined;
1532
+ // Guard against prototype pollution: only honor own properties.
1533
+ var withXSRFToken = utils.hasOwnProperty(config, 'withXSRFToken')
1534
+ ? config.withXSRFToken
1535
+ : undefined;
1367
1536
  var onCanceled;
1368
1537
  function done() {
1369
1538
  if (config.cancelToken) {
@@ -1382,15 +1551,30 @@
1382
1551
  var request = new XMLHttpRequest();
1383
1552
 
1384
1553
  // HTTP basic authentication
1385
- if (config.auth) {
1386
- var username = config.auth.username || '';
1387
- var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
1554
+ var configAuth = utils.hasOwnProperty(config, 'auth') ? config.auth : undefined;
1555
+ if (configAuth) {
1556
+ var username = utils.hasOwnProperty(configAuth, 'username') ? configAuth.username || '' : '';
1557
+ var password = utils.hasOwnProperty(configAuth, 'password') && configAuth.password
1558
+ ? unescape(encodeURIComponent(configAuth.password))
1559
+ : '';
1388
1560
  requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
1389
1561
  }
1390
1562
 
1391
- var fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
1563
+ var fullPath = buildFullPath(
1564
+ config.baseURL,
1565
+ config.url,
1566
+ config.allowAbsoluteUrls
1567
+ );
1392
1568
 
1393
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
1569
+ request.open(
1570
+ config.method.toUpperCase(),
1571
+ buildURL(
1572
+ fullPath,
1573
+ config.params,
1574
+ utils.hasOwnProperty(config, 'paramsSerializer') ? config.paramsSerializer : undefined
1575
+ ),
1576
+ true
1577
+ );
1394
1578
 
1395
1579
  // Set the request timeout in MS
1396
1580
  request.timeout = config.timeout;
@@ -1400,9 +1584,14 @@
1400
1584
  return;
1401
1585
  }
1402
1586
  // Prepare the response
1403
- var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
1404
- var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
1405
- request.responseText : request.response;
1587
+ var responseHeaders =
1588
+ 'getAllResponseHeaders' in request
1589
+ ? parseHeaders(request.getAllResponseHeaders())
1590
+ : null;
1591
+ var responseData =
1592
+ !responseType || responseType === 'text' || responseType === 'json'
1593
+ ? request.responseText
1594
+ : request.response;
1406
1595
  var response = {
1407
1596
  data: responseData,
1408
1597
  status: request.status,
@@ -1412,13 +1601,17 @@
1412
1601
  request: request
1413
1602
  };
1414
1603
 
1415
- settle(function _resolve(value) {
1416
- resolve(value);
1417
- done();
1418
- }, function _reject(err) {
1419
- reject(err);
1420
- done();
1421
- }, response);
1604
+ settle(
1605
+ function _resolve(value) {
1606
+ resolve(value);
1607
+ done();
1608
+ },
1609
+ function _reject(err) {
1610
+ reject(err);
1611
+ done();
1612
+ },
1613
+ response
1614
+ );
1422
1615
 
1423
1616
  // Clean up request
1424
1617
  request = null;
@@ -1438,7 +1631,10 @@
1438
1631
  // handled by onerror instead
1439
1632
  // With one exception: request that using file: protocol, most browsers
1440
1633
  // will return status as 0 even though it's a successful request
1441
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
1634
+ if (
1635
+ request.status === 0 &&
1636
+ !(request.responseURL && request.responseURL.indexOf('file:') === 0)
1637
+ ) {
1442
1638
  return;
1443
1639
  }
1444
1640
  // readystate handler is calling before onerror or ontimeout handlers,
@@ -1453,7 +1649,14 @@
1453
1649
  return;
1454
1650
  }
1455
1651
 
1456
- reject(new AxiosError_1('Request aborted', AxiosError_1.ECONNABORTED, config, request));
1652
+ reject(
1653
+ new AxiosError_1(
1654
+ 'Request aborted',
1655
+ AxiosError_1.ECONNABORTED,
1656
+ config,
1657
+ request
1658
+ )
1659
+ );
1457
1660
 
1458
1661
  // Clean up request
1459
1662
  request = null;
@@ -1463,7 +1666,14 @@
1463
1666
  request.onerror = function handleError() {
1464
1667
  // Real errors are hidden from us by the browser
1465
1668
  // onerror should only fire if it's a network error
1466
- reject(new AxiosError_1('Network Error', AxiosError_1.ERR_NETWORK, config, request));
1669
+ reject(
1670
+ new AxiosError_1(
1671
+ 'Network Error',
1672
+ AxiosError_1.ERR_NETWORK,
1673
+ config,
1674
+ request
1675
+ )
1676
+ );
1467
1677
 
1468
1678
  // Clean up request
1469
1679
  request = null;
@@ -1471,16 +1681,23 @@
1471
1681
 
1472
1682
  // Handle timeout
1473
1683
  request.ontimeout = function handleTimeout() {
1474
- var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
1684
+ var timeoutErrorMessage = config.timeout
1685
+ ? 'timeout of ' + config.timeout + 'ms exceeded'
1686
+ : 'timeout exceeded';
1475
1687
  var transitional$1 = config.transitional || transitional;
1476
1688
  if (config.timeoutErrorMessage) {
1477
1689
  timeoutErrorMessage = config.timeoutErrorMessage;
1478
1690
  }
1479
- reject(new AxiosError_1(
1480
- timeoutErrorMessage,
1481
- transitional$1.clarifyTimeoutError ? AxiosError_1.ETIMEDOUT : AxiosError_1.ECONNABORTED,
1482
- config,
1483
- request));
1691
+ reject(
1692
+ new AxiosError_1(
1693
+ timeoutErrorMessage,
1694
+ transitional$1.clarifyTimeoutError
1695
+ ? AxiosError_1.ETIMEDOUT
1696
+ : AxiosError_1.ECONNABORTED,
1697
+ config,
1698
+ request
1699
+ )
1700
+ );
1484
1701
 
1485
1702
  // Clean up request
1486
1703
  request = null;
@@ -1494,10 +1711,16 @@
1494
1711
  if (utils.isFunction(withXSRFToken)) {
1495
1712
  withXSRFToken = withXSRFToken(config);
1496
1713
  }
1497
- // Strict boolean check (GHSA-xx6v-rp6x-q39c): only `true` short-circuits the same-origin guard.
1498
- if (withXSRFToken === true || (withXSRFToken !== false && isURLSameOrigin(fullPath))) {
1714
+ // Strict boolean check: only `true` short-circuits the same-origin guard.
1715
+ if (
1716
+ withXSRFToken === true ||
1717
+ (withXSRFToken !== false && isURLSameOrigin(fullPath))
1718
+ ) {
1499
1719
  // Add xsrf header
1500
- var xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
1720
+ var xsrfValue =
1721
+ config.xsrfHeaderName &&
1722
+ config.xsrfCookieName &&
1723
+ cookies.read(config.xsrfCookieName);
1501
1724
  if (xsrfValue) {
1502
1725
  requestHeaders[config.xsrfHeaderName] = xsrfValue;
1503
1726
  }
@@ -1507,7 +1730,10 @@
1507
1730
  // Add headers to the request
1508
1731
  if ('setRequestHeader' in request) {
1509
1732
  utils.forEach(requestHeaders, function setRequestHeader(val, key) {
1510
- if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
1733
+ if (
1734
+ typeof requestData === 'undefined' &&
1735
+ key.toLowerCase() === 'content-type'
1736
+ ) {
1511
1737
  // Remove Content-Type if data is undefined
1512
1738
  delete requestHeaders[key];
1513
1739
  } else {
@@ -1544,30 +1770,46 @@
1544
1770
  if (!request) {
1545
1771
  return;
1546
1772
  }
1547
- reject(!cancel || cancel.type ? new CanceledError_1(null, config, request) : cancel);
1773
+ reject(
1774
+ !cancel || cancel.type
1775
+ ? new CanceledError_1(null, config, request)
1776
+ : cancel
1777
+ );
1548
1778
  request.abort();
1549
1779
  request = null;
1550
1780
  };
1551
1781
 
1552
1782
  config.cancelToken && config.cancelToken.subscribe(onCanceled);
1553
1783
  if (config.signal) {
1554
- config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
1784
+ config.signal.aborted
1785
+ ? onCanceled()
1786
+ : config.signal.addEventListener('abort', onCanceled);
1555
1787
  }
1556
1788
  }
1557
1789
 
1558
1790
  // false, 0 (zero number), and '' (empty string) are valid JSON values
1559
- if (!requestData && requestData !== false && requestData !== 0 && requestData !== '') {
1791
+ if (
1792
+ !requestData &&
1793
+ requestData !== false &&
1794
+ requestData !== 0 &&
1795
+ requestData !== ''
1796
+ ) {
1560
1797
  requestData = null;
1561
1798
  }
1562
1799
 
1563
1800
  var protocol = parseProtocol(fullPath);
1564
1801
 
1565
1802
  if (protocol && platform.protocols.indexOf(protocol) === -1) {
1566
- reject(new AxiosError_1('Unsupported protocol ' + protocol + ':', AxiosError_1.ERR_BAD_REQUEST, config));
1803
+ reject(
1804
+ new AxiosError_1(
1805
+ 'Unsupported protocol ' + protocol + ':',
1806
+ AxiosError_1.ERR_BAD_REQUEST,
1807
+ config
1808
+ )
1809
+ );
1567
1810
  return;
1568
1811
  }
1569
1812
 
1570
-
1571
1813
  // Send the request
1572
1814
  request.send(requestData);
1573
1815
  });
@@ -1715,6 +1957,8 @@
1715
1957
  maxContentLength: -1,
1716
1958
  maxBodyLength: -1,
1717
1959
 
1960
+ redact: defaultRedactKeys.slice(),
1961
+
1718
1962
  env: {
1719
1963
  FormData: platform.classes.FormData,
1720
1964
  Blob: platform.classes.Blob
@@ -1821,11 +2065,16 @@
1821
2065
  normalizeHeaderName(config.headers, 'Content-Type');
1822
2066
 
1823
2067
  // Flatten headers
1824
- config.headers = utils.merge(
1825
- config.headers.common || {},
1826
- config.headers[config.method] || {},
1827
- config.headers
1828
- );
2068
+ var commonHeaders = utils.hasOwnProperty(config.headers, 'common') && config.headers.common
2069
+ ? config.headers.common
2070
+ : {};
2071
+ var methodHeaders = config.method &&
2072
+ utils.hasOwnProperty(config.headers, config.method) &&
2073
+ config.headers[config.method]
2074
+ ? config.headers[config.method]
2075
+ : {};
2076
+
2077
+ config.headers = utils.merge(commonHeaders, methodHeaders, config.headers);
1829
2078
 
1830
2079
  utils.forEach(
1831
2080
  ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
@@ -1970,6 +2219,7 @@
1970
2219
  'httpsAgent': defaultToConfig2,
1971
2220
  'cancelToken': defaultToConfig2,
1972
2221
  'socketPath': defaultToConfig2,
2222
+ 'allowedSocketPaths': defaultToConfig2,
1973
2223
  'responseEncoding': defaultToConfig2,
1974
2224
  'validateStatus': mergeDirectKeys
1975
2225
  };
@@ -1987,7 +2237,7 @@
1987
2237
  };
1988
2238
 
1989
2239
  var data = {
1990
- "version": "0.31.1"
2240
+ "version": "0.33.0"
1991
2241
  };
1992
2242
 
1993
2243
  var VERSION = data.version;
@@ -2211,10 +2461,12 @@
2211
2461
  utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
2212
2462
  /*eslint func-names:0*/
2213
2463
  Axios.prototype[method] = function(url, config) {
2214
- return this.request(mergeConfig(config || {}, {
2464
+ var requestConfig = config || {};
2465
+
2466
+ return this.request(mergeConfig(requestConfig, {
2215
2467
  method: method,
2216
2468
  url: url,
2217
- data: (config || {}).data
2469
+ data: utils.hasOwnProperty(requestConfig, 'data') ? requestConfig.data : undefined
2218
2470
  }));
2219
2471
  };
2220
2472
  });