axios 0.31.0 → 0.32.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.0 Copyright (c) 2026 Matt Zabriskie
1
+ // axios v0.32.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
  }
@@ -215,8 +220,16 @@
215
220
  */
216
221
  function isFormData(thing) {
217
222
  var pattern = '[object FormData]';
218
- return thing && (
219
- (typeof FormData === 'function' && thing instanceof FormData) ||
223
+ if (!thing) return false;
224
+ if (typeof FormData === 'function' && thing instanceof FormData) return true;
225
+ // Reject non-objects (strings, numbers, booleans) up front — Object.getPrototypeOf
226
+ // throws a TypeError on primitives in ES5 environments.
227
+ if (!isObject(thing)) return false;
228
+ // Reject plain objects inheriting directly from Object.prototype so prototype-pollution gadgets can't spoof FormData.
229
+ var proto = Object.getPrototypeOf(thing);
230
+ if (!proto || proto === Object.prototype) return false;
231
+ if (!isFunction(thing.append)) return false;
232
+ return (
220
233
  toString.call(thing) === pattern ||
221
234
  (isFunction(thing.toString) && thing.toString() === pattern)
222
235
  );
@@ -237,7 +250,9 @@
237
250
  * @returns {String} The String freed of excess whitespace
238
251
  */
239
252
  function trim(str) {
240
- 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, '');
241
256
  }
242
257
 
243
258
  /**
@@ -257,10 +272,11 @@
257
272
  */
258
273
  function isStandardBrowserEnv() {
259
274
  var product;
260
- if (typeof navigator !== 'undefined' && (
261
- (product = navigator.product) === 'ReactNative' ||
262
- product === 'NativeScript' ||
263
- product === 'NS')
275
+ if (
276
+ typeof navigator !== 'undefined' &&
277
+ ((product = navigator.product) === 'ReactNative' ||
278
+ product === 'NativeScript' ||
279
+ product === 'NS')
264
280
  ) {
265
281
  return false;
266
282
  }
@@ -325,14 +341,20 @@
325
341
  * @returns {Object} Result of all merge properties
326
342
  */
327
343
  function merge(/* obj1, obj2, obj3, ... */) {
328
- var result = {};
344
+ var result = Object.create(null);
329
345
  function assignValue(val, key) {
346
+ var target;
347
+
330
348
  if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
331
349
  return;
332
350
  }
333
351
 
334
- if (isPlainObject(result[key]) && isPlainObject(val)) {
335
- 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);
336
358
  } else if (isPlainObject(val)) {
337
359
  result[key] = merge({}, val);
338
360
  } else if (isArray(val)) {
@@ -374,7 +396,7 @@
374
396
  * @return {string} content value without BOM
375
397
  */
376
398
  function stripBOM(content) {
377
- if (content.charCodeAt(0) === 0xFEFF) {
399
+ if (content.charCodeAt(0) === 0xfeff) {
378
400
  content = content.slice(1);
379
401
  }
380
402
  return content;
@@ -389,7 +411,10 @@
389
411
  */
390
412
 
391
413
  function inherits(constructor, superConstructor, props, descriptors) {
392
- constructor.prototype = Object.create(superConstructor.prototype, descriptors);
414
+ constructor.prototype = Object.create(
415
+ superConstructor.prototype,
416
+ descriptors
417
+ );
393
418
  constructor.prototype.constructor = constructor;
394
419
  props && Object.assign(constructor.prototype, props);
395
420
  }
@@ -418,13 +443,20 @@
418
443
  i = props.length;
419
444
  while (i-- > 0) {
420
445
  prop = props[i];
421
- if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
446
+ if (
447
+ (!propFilter || propFilter(prop, sourceObj, destObj)) &&
448
+ !merged[prop]
449
+ ) {
422
450
  destObj[prop] = sourceObj[prop];
423
451
  merged[prop] = true;
424
452
  }
425
453
  }
426
454
  sourceObj = filter !== false && Object.getPrototypeOf(sourceObj);
427
- } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
455
+ } while (
456
+ sourceObj &&
457
+ (!filter || filter(sourceObj, destObj)) &&
458
+ sourceObj !== Object.prototype
459
+ );
428
460
 
429
461
  return destObj;
430
462
  }
@@ -446,7 +478,6 @@
446
478
  return lastIndex !== -1 && lastIndex === position;
447
479
  }
448
480
 
449
-
450
481
  /**
451
482
  * Returns new array from array like object or null if failed
452
483
  * @param {*} [thing]
@@ -542,6 +573,82 @@
542
573
  hasOwnProperty: hasOwnProperty
543
574
  };
544
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
+
545
652
  /**
546
653
  * Create an Error with the specified message, config, error code, request and response.
547
654
  *
@@ -584,7 +691,7 @@
584
691
  columnNumber: this.columnNumber,
585
692
  stack: this.stack,
586
693
  // Axios
587
- config: this.config,
694
+ config: serializeConfig(this.config),
588
695
  code: this.code,
589
696
  status: this.response && this.response.status ? this.response.status : null
590
697
  };
@@ -592,7 +699,7 @@
592
699
  });
593
700
 
594
701
  var prototype$1 = AxiosError.prototype;
595
- var descriptors = {};
702
+ var descriptors = Object.create(null);
596
703
 
597
704
  [
598
705
  'ERR_BAD_OPTION_VALUE',
@@ -606,14 +713,15 @@
606
713
  'ERR_BAD_REQUEST',
607
714
  'ERR_CANCELED',
608
715
  'ERR_NOT_SUPPORT',
609
- 'ERR_INVALID_URL'
716
+ 'ERR_INVALID_URL',
717
+ 'ERR_FORM_DATA_DEPTH_EXCEEDED'
610
718
  // eslint-disable-next-line func-names
611
719
  ].forEach(function(code) {
612
- descriptors[code] = {value: code};
720
+ descriptors[code] = makeValueDescriptor(code);
613
721
  });
614
722
 
615
723
  Object.defineProperties(AxiosError, descriptors);
616
- Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
724
+ Object.defineProperty(prototype$1, 'isAxiosError', makeValueDescriptor(true));
617
725
 
618
726
  // eslint-disable-next-line func-names
619
727
  AxiosError.from = function(error, code, config, request, response, customProps) {
@@ -707,6 +815,7 @@
707
815
  var dots = options.dots;
708
816
  var indexes = options.indexes;
709
817
  var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
818
+ var maxDepth = options.maxDepth === undefined ? 100 : options.maxDepth;
710
819
  var useBlob = _Blob && isSpecCompliant(formData);
711
820
 
712
821
  if (!utils.isFunction(visitor)) {
@@ -783,9 +892,19 @@
783
892
  isVisitable: isVisitable
784
893
  });
785
894
 
786
- function build(value, path) {
895
+ function build(value, path, depth) {
787
896
  if (utils.isUndefined(value)) return;
788
897
 
898
+ // eslint-disable-next-line no-param-reassign
899
+ depth = depth || 0;
900
+
901
+ if (depth > maxDepth) {
902
+ throw new AxiosError_1(
903
+ 'Maximum object depth of ' + maxDepth + ' exceeded (got ' + depth + ' levels)',
904
+ AxiosError_1.ERR_FORM_DATA_DEPTH_EXCEEDED
905
+ );
906
+ }
907
+
789
908
  if (stack.indexOf(value) !== -1) {
790
909
  throw Error('Circular reference detected in ' + path.join('.'));
791
910
  }
@@ -798,7 +917,7 @@
798
917
  );
799
918
 
800
919
  if (result === true) {
801
- build(el, path ? path.concat(key) : [key]);
920
+ build(el, path ? path.concat(key) : [key], depth + 1);
802
921
  }
803
922
  });
804
923
 
@@ -809,7 +928,7 @@
809
928
  throw new TypeError('data must be an object');
810
929
  }
811
930
 
812
- build(obj);
931
+ build(obj, null, 0);
813
932
 
814
933
  return formData;
815
934
  }
@@ -817,18 +936,22 @@
817
936
  var toFormData_1 = toFormData;
818
937
 
819
938
  function encode$1(str) {
939
+ // Do not map `%00` back to a raw null byte: that reversed
940
+ // the safe percent-encoding from encodeURIComponent and enabled null byte injection.
820
941
  var charMap = {
821
942
  '!': '%21',
822
943
  "'": '%27',
823
944
  '(': '%28',
824
945
  ')': '%29',
825
946
  '~': '%7E',
826
- '%20': '+',
827
- '%00': '\x00'
947
+ '%20': '+'
828
948
  };
829
- return encodeURIComponent(str).replace(/[!'\(\)~]|%20|%00/g, function replacer(match) {
830
- return charMap[match];
831
- });
949
+ return encodeURIComponent(str).replace(
950
+ /[!'\(\)~]|%20/g,
951
+ function replacer(match) {
952
+ return charMap[match];
953
+ }
954
+ );
832
955
  }
833
956
 
834
957
  function AxiosURLSearchParams(params, options) {
@@ -844,13 +967,17 @@
844
967
  };
845
968
 
846
969
  prototype.toString = function toString(encoder) {
847
- var _encode = encoder ? function(value) {
848
- return encoder.call(this, value, encode$1);
849
- } : encode$1;
970
+ var _encode = encoder
971
+ ? function(value) {
972
+ return encoder.call(this, value, encode$1);
973
+ }
974
+ : encode$1;
850
975
 
851
- return this._pairs.map(function each(pair) {
852
- return _encode(pair[0]) + '=' + _encode(pair[1]);
853
- }, '').join('&');
976
+ return this._pairs
977
+ .map(function each(pair) {
978
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
979
+ }, '')
980
+ .join('&');
854
981
  };
855
982
 
856
983
  var AxiosURLSearchParams_1 = AxiosURLSearchParams;
@@ -1133,8 +1260,21 @@
1133
1260
  },
1134
1261
 
1135
1262
  read: function read(name) {
1136
- var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1137
- return (match ? decodeURIComponent(match[3]) : null);
1263
+ var nameEQ = name + '=';
1264
+ var cookies = document.cookie.split(';');
1265
+ var cookie;
1266
+
1267
+ for (var i = 0; i < cookies.length; i++) {
1268
+ cookie = cookies[i];
1269
+ while (cookie.charAt(0) === ' ') {
1270
+ cookie = cookie.substring(1);
1271
+ }
1272
+ if (cookie.indexOf(nameEQ) === 0) {
1273
+ return decodeURIComponent(cookie.substring(nameEQ.length));
1274
+ }
1275
+ }
1276
+
1277
+ return null;
1138
1278
  },
1139
1279
 
1140
1280
  remove: function remove(name) {
@@ -1343,7 +1483,10 @@
1343
1483
  var requestData = config.data;
1344
1484
  var requestHeaders = config.headers;
1345
1485
  var responseType = config.responseType;
1346
- var withXSRFToken = config.withXSRFToken;
1486
+ // Guard against prototype pollution: only honor own properties.
1487
+ var withXSRFToken = utils.hasOwnProperty(config, 'withXSRFToken')
1488
+ ? config.withXSRFToken
1489
+ : undefined;
1347
1490
  var onCanceled;
1348
1491
  function done() {
1349
1492
  if (config.cancelToken) {
@@ -1364,13 +1507,23 @@
1364
1507
  // HTTP basic authentication
1365
1508
  if (config.auth) {
1366
1509
  var username = config.auth.username || '';
1367
- var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
1510
+ var password = config.auth.password
1511
+ ? unescape(encodeURIComponent(config.auth.password))
1512
+ : '';
1368
1513
  requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
1369
1514
  }
1370
1515
 
1371
- var fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
1516
+ var fullPath = buildFullPath(
1517
+ config.baseURL,
1518
+ config.url,
1519
+ config.allowAbsoluteUrls
1520
+ );
1372
1521
 
1373
- request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
1522
+ request.open(
1523
+ config.method.toUpperCase(),
1524
+ buildURL(fullPath, config.params, config.paramsSerializer),
1525
+ true
1526
+ );
1374
1527
 
1375
1528
  // Set the request timeout in MS
1376
1529
  request.timeout = config.timeout;
@@ -1380,9 +1533,14 @@
1380
1533
  return;
1381
1534
  }
1382
1535
  // Prepare the response
1383
- var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
1384
- var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
1385
- request.responseText : request.response;
1536
+ var responseHeaders =
1537
+ 'getAllResponseHeaders' in request
1538
+ ? parseHeaders(request.getAllResponseHeaders())
1539
+ : null;
1540
+ var responseData =
1541
+ !responseType || responseType === 'text' || responseType === 'json'
1542
+ ? request.responseText
1543
+ : request.response;
1386
1544
  var response = {
1387
1545
  data: responseData,
1388
1546
  status: request.status,
@@ -1392,13 +1550,17 @@
1392
1550
  request: request
1393
1551
  };
1394
1552
 
1395
- settle(function _resolve(value) {
1396
- resolve(value);
1397
- done();
1398
- }, function _reject(err) {
1399
- reject(err);
1400
- done();
1401
- }, response);
1553
+ settle(
1554
+ function _resolve(value) {
1555
+ resolve(value);
1556
+ done();
1557
+ },
1558
+ function _reject(err) {
1559
+ reject(err);
1560
+ done();
1561
+ },
1562
+ response
1563
+ );
1402
1564
 
1403
1565
  // Clean up request
1404
1566
  request = null;
@@ -1418,7 +1580,10 @@
1418
1580
  // handled by onerror instead
1419
1581
  // With one exception: request that using file: protocol, most browsers
1420
1582
  // will return status as 0 even though it's a successful request
1421
- if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
1583
+ if (
1584
+ request.status === 0 &&
1585
+ !(request.responseURL && request.responseURL.indexOf('file:') === 0)
1586
+ ) {
1422
1587
  return;
1423
1588
  }
1424
1589
  // readystate handler is calling before onerror or ontimeout handlers,
@@ -1433,7 +1598,14 @@
1433
1598
  return;
1434
1599
  }
1435
1600
 
1436
- reject(new AxiosError_1('Request aborted', AxiosError_1.ECONNABORTED, config, request));
1601
+ reject(
1602
+ new AxiosError_1(
1603
+ 'Request aborted',
1604
+ AxiosError_1.ECONNABORTED,
1605
+ config,
1606
+ request
1607
+ )
1608
+ );
1437
1609
 
1438
1610
  // Clean up request
1439
1611
  request = null;
@@ -1443,7 +1615,14 @@
1443
1615
  request.onerror = function handleError() {
1444
1616
  // Real errors are hidden from us by the browser
1445
1617
  // onerror should only fire if it's a network error
1446
- reject(new AxiosError_1('Network Error', AxiosError_1.ERR_NETWORK, config, request));
1618
+ reject(
1619
+ new AxiosError_1(
1620
+ 'Network Error',
1621
+ AxiosError_1.ERR_NETWORK,
1622
+ config,
1623
+ request
1624
+ )
1625
+ );
1447
1626
 
1448
1627
  // Clean up request
1449
1628
  request = null;
@@ -1451,16 +1630,23 @@
1451
1630
 
1452
1631
  // Handle timeout
1453
1632
  request.ontimeout = function handleTimeout() {
1454
- var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
1633
+ var timeoutErrorMessage = config.timeout
1634
+ ? 'timeout of ' + config.timeout + 'ms exceeded'
1635
+ : 'timeout exceeded';
1455
1636
  var transitional$1 = config.transitional || transitional;
1456
1637
  if (config.timeoutErrorMessage) {
1457
1638
  timeoutErrorMessage = config.timeoutErrorMessage;
1458
1639
  }
1459
- reject(new AxiosError_1(
1460
- timeoutErrorMessage,
1461
- transitional$1.clarifyTimeoutError ? AxiosError_1.ETIMEDOUT : AxiosError_1.ECONNABORTED,
1462
- config,
1463
- request));
1640
+ reject(
1641
+ new AxiosError_1(
1642
+ timeoutErrorMessage,
1643
+ transitional$1.clarifyTimeoutError
1644
+ ? AxiosError_1.ETIMEDOUT
1645
+ : AxiosError_1.ECONNABORTED,
1646
+ config,
1647
+ request
1648
+ )
1649
+ );
1464
1650
 
1465
1651
  // Clean up request
1466
1652
  request = null;
@@ -1471,10 +1657,19 @@
1471
1657
  // Specifically not if we're in a web worker, or react-native.
1472
1658
  if (utils.isStandardBrowserEnv()) {
1473
1659
  // Add xsrf header
1474
- withXSRFToken && utils.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config));
1475
- if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(fullPath))) {
1660
+ if (utils.isFunction(withXSRFToken)) {
1661
+ withXSRFToken = withXSRFToken(config);
1662
+ }
1663
+ // Strict boolean check: only `true` short-circuits the same-origin guard.
1664
+ if (
1665
+ withXSRFToken === true ||
1666
+ (withXSRFToken !== false && isURLSameOrigin(fullPath))
1667
+ ) {
1476
1668
  // Add xsrf header
1477
- var xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
1669
+ var xsrfValue =
1670
+ config.xsrfHeaderName &&
1671
+ config.xsrfCookieName &&
1672
+ cookies.read(config.xsrfCookieName);
1478
1673
  if (xsrfValue) {
1479
1674
  requestHeaders[config.xsrfHeaderName] = xsrfValue;
1480
1675
  }
@@ -1484,7 +1679,10 @@
1484
1679
  // Add headers to the request
1485
1680
  if ('setRequestHeader' in request) {
1486
1681
  utils.forEach(requestHeaders, function setRequestHeader(val, key) {
1487
- if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
1682
+ if (
1683
+ typeof requestData === 'undefined' &&
1684
+ key.toLowerCase() === 'content-type'
1685
+ ) {
1488
1686
  // Remove Content-Type if data is undefined
1489
1687
  delete requestHeaders[key];
1490
1688
  } else {
@@ -1521,30 +1719,46 @@
1521
1719
  if (!request) {
1522
1720
  return;
1523
1721
  }
1524
- reject(!cancel || cancel.type ? new CanceledError_1(null, config, request) : cancel);
1722
+ reject(
1723
+ !cancel || cancel.type
1724
+ ? new CanceledError_1(null, config, request)
1725
+ : cancel
1726
+ );
1525
1727
  request.abort();
1526
1728
  request = null;
1527
1729
  };
1528
1730
 
1529
1731
  config.cancelToken && config.cancelToken.subscribe(onCanceled);
1530
1732
  if (config.signal) {
1531
- config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
1733
+ config.signal.aborted
1734
+ ? onCanceled()
1735
+ : config.signal.addEventListener('abort', onCanceled);
1532
1736
  }
1533
1737
  }
1534
1738
 
1535
1739
  // false, 0 (zero number), and '' (empty string) are valid JSON values
1536
- if (!requestData && requestData !== false && requestData !== 0 && requestData !== '') {
1740
+ if (
1741
+ !requestData &&
1742
+ requestData !== false &&
1743
+ requestData !== 0 &&
1744
+ requestData !== ''
1745
+ ) {
1537
1746
  requestData = null;
1538
1747
  }
1539
1748
 
1540
1749
  var protocol = parseProtocol(fullPath);
1541
1750
 
1542
1751
  if (protocol && platform.protocols.indexOf(protocol) === -1) {
1543
- reject(new AxiosError_1('Unsupported protocol ' + protocol + ':', AxiosError_1.ERR_BAD_REQUEST, config));
1752
+ reject(
1753
+ new AxiosError_1(
1754
+ 'Unsupported protocol ' + protocol + ':',
1755
+ AxiosError_1.ERR_BAD_REQUEST,
1756
+ config
1757
+ )
1758
+ );
1544
1759
  return;
1545
1760
  }
1546
1761
 
1547
-
1548
1762
  // Send the request
1549
1763
  request.send(requestData);
1550
1764
  });
@@ -1630,17 +1844,20 @@
1630
1844
  var isFileList;
1631
1845
 
1632
1846
  if (isObjectPayload) {
1847
+ var formSerializer = utils.hasOwnProperty(this, 'formSerializer') ? this.formSerializer : undefined;
1848
+ var envOption = utils.hasOwnProperty(this, 'env') ? this.env : undefined;
1849
+
1633
1850
  if (contentType.indexOf('application/x-www-form-urlencoded') !== -1) {
1634
- return toURLEncodedForm(data, this.formSerializer).toString();
1851
+ return toURLEncodedForm(data, formSerializer).toString();
1635
1852
  }
1636
1853
 
1637
1854
  if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1638
- var _FormData = this.env && this.env.FormData;
1855
+ var _FormData = envOption && envOption.FormData;
1639
1856
 
1640
1857
  return toFormData_1(
1641
1858
  isFileList ? {'files[]': data} : data,
1642
1859
  _FormData && new _FormData(),
1643
- this.formSerializer
1860
+ formSerializer
1644
1861
  );
1645
1862
  }
1646
1863
  }
@@ -1689,6 +1906,8 @@
1689
1906
  maxContentLength: -1,
1690
1907
  maxBodyLength: -1,
1691
1908
 
1909
+ redact: defaultRedactKeys.slice(),
1910
+
1692
1911
  env: {
1693
1912
  FormData: platform.classes.FormData,
1694
1913
  Blob: platform.classes.Blob
@@ -1795,11 +2014,16 @@
1795
2014
  normalizeHeaderName(config.headers, 'Content-Type');
1796
2015
 
1797
2016
  // Flatten headers
1798
- config.headers = utils.merge(
1799
- config.headers.common || {},
1800
- config.headers[config.method] || {},
1801
- config.headers
1802
- );
2017
+ var commonHeaders = utils.hasOwnProperty(config.headers, 'common') && config.headers.common
2018
+ ? config.headers.common
2019
+ : {};
2020
+ var methodHeaders = config.method &&
2021
+ utils.hasOwnProperty(config.headers, config.method) &&
2022
+ config.headers[config.method]
2023
+ ? config.headers[config.method]
2024
+ : {};
2025
+
2026
+ config.headers = utils.merge(commonHeaders, methodHeaders, config.headers);
1803
2027
 
1804
2028
  utils.forEach(
1805
2029
  ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
@@ -1858,7 +2082,17 @@
1858
2082
  var mergeConfig = function mergeConfig(config1, config2) {
1859
2083
  // eslint-disable-next-line no-param-reassign
1860
2084
  config2 = config2 || {};
1861
- var config = {};
2085
+ // Use a null-prototype object so a polluted Object.prototype cannot leak
2086
+ // values (e.g. transport, adapter) into the returned config via inheritance.
2087
+ var config = Object.create(null);
2088
+
2089
+ function getOwn(source, prop) {
2090
+ return utils.hasOwnProperty(source, prop) ? source[prop] : undefined;
2091
+ }
2092
+
2093
+ function hasOwn(source, prop) {
2094
+ return utils.hasOwnProperty(source, prop);
2095
+ }
1862
2096
 
1863
2097
  function getMergedValue(target, source) {
1864
2098
  if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
@@ -1875,34 +2109,34 @@
1875
2109
 
1876
2110
  // eslint-disable-next-line consistent-return
1877
2111
  function mergeDeepProperties(prop) {
1878
- if (!utils.isUndefined(config2[prop])) {
1879
- return getMergedValue(config1[prop], config2[prop]);
1880
- } else if (!utils.isUndefined(config1[prop])) {
2112
+ if (hasOwn(config2, prop) && !utils.isUndefined(config2[prop])) {
2113
+ return getMergedValue(getOwn(config1, prop), config2[prop]);
2114
+ } else if (hasOwn(config1, prop) && !utils.isUndefined(config1[prop])) {
1881
2115
  return getMergedValue(undefined, config1[prop]);
1882
2116
  }
1883
2117
  }
1884
2118
 
1885
2119
  // eslint-disable-next-line consistent-return
1886
2120
  function valueFromConfig2(prop) {
1887
- if (!utils.isUndefined(config2[prop])) {
2121
+ if (hasOwn(config2, prop) && !utils.isUndefined(config2[prop])) {
1888
2122
  return getMergedValue(undefined, config2[prop]);
1889
2123
  }
1890
2124
  }
1891
2125
 
1892
2126
  // eslint-disable-next-line consistent-return
1893
2127
  function defaultToConfig2(prop) {
1894
- if (!utils.isUndefined(config2[prop])) {
2128
+ if (hasOwn(config2, prop) && !utils.isUndefined(config2[prop])) {
1895
2129
  return getMergedValue(undefined, config2[prop]);
1896
- } else if (!utils.isUndefined(config1[prop])) {
2130
+ } else if (hasOwn(config1, prop) && !utils.isUndefined(config1[prop])) {
1897
2131
  return getMergedValue(undefined, config1[prop]);
1898
2132
  }
1899
2133
  }
1900
2134
 
1901
2135
  // eslint-disable-next-line consistent-return
1902
2136
  function mergeDirectKeys(prop) {
1903
- if (prop in config2) {
1904
- return getMergedValue(config1[prop], config2[prop]);
1905
- } else if (prop in config1) {
2137
+ if (hasOwn(config2, prop)) {
2138
+ return getMergedValue(getOwn(config1, prop), config2[prop]);
2139
+ } else if (hasOwn(config1, prop)) {
1906
2140
  return getMergedValue(undefined, config1[prop]);
1907
2141
  }
1908
2142
  }
@@ -1934,6 +2168,7 @@
1934
2168
  'httpsAgent': defaultToConfig2,
1935
2169
  'cancelToken': defaultToConfig2,
1936
2170
  'socketPath': defaultToConfig2,
2171
+ 'allowedSocketPaths': defaultToConfig2,
1937
2172
  'responseEncoding': defaultToConfig2,
1938
2173
  'validateStatus': mergeDirectKeys
1939
2174
  };
@@ -1951,7 +2186,7 @@
1951
2186
  };
1952
2187
 
1953
2188
  var data = {
1954
- "version": "0.31.0"
2189
+ "version": "0.32.0"
1955
2190
  };
1956
2191
 
1957
2192
  var VERSION = data.version;