axios 1.1.1 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

package/dist/esm/axios.js CHANGED
@@ -1,4 +1,4 @@
1
- // Axios v1.1.1 Copyright (c) 2022 Matt Zabriskie and contributors
1
+ // Axios v1.1.3 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);
@@ -877,7 +877,7 @@ function toFormData(obj, formData, options) {
877
877
  key = removeBrackets(key);
878
878
 
879
879
  arr.forEach(function each(el, index) {
880
- !utils.isUndefined(el) && formData.append(
880
+ !(utils.isUndefined(el) || el === null) && formData.append(
881
881
  // eslint-disable-next-line no-nested-ternary
882
882
  indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
883
883
  convertValue(el)
@@ -914,7 +914,7 @@ function toFormData(obj, formData, options) {
914
914
  stack.push(value);
915
915
 
916
916
  utils.forEach(value, function each(el, key) {
917
- const result = !utils.isUndefined(el) && visitor.call(
917
+ const result = !(utils.isUndefined(el) || el === null) && visitor.call(
918
918
  formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers
919
919
  );
920
920
 
@@ -1020,21 +1020,28 @@ function buildURL(url, params, options) {
1020
1020
  if (!params) {
1021
1021
  return url;
1022
1022
  }
1023
+
1024
+ const _encode = options && options.encode || encode;
1023
1025
 
1024
- const hashmarkIndex = url.indexOf('#');
1026
+ const serializeFn = options && options.serialize;
1025
1027
 
1026
- if (hashmarkIndex !== -1) {
1027
- url = url.slice(0, hashmarkIndex);
1028
- }
1028
+ let serializedParams;
1029
1029
 
1030
- const _encode = options && options.encode || encode;
1030
+ if (serializeFn) {
1031
+ serializedParams = serializeFn(params, options);
1032
+ } else {
1033
+ serializedParams = utils.isURLSearchParams(params) ?
1034
+ params.toString() :
1035
+ new AxiosURLSearchParams(params, options).toString(_encode);
1036
+ }
1031
1037
 
1032
- const serializerParams = utils.isURLSearchParams(params) ?
1033
- params.toString() :
1034
- new AxiosURLSearchParams(params, options).toString(_encode);
1038
+ if (serializedParams) {
1039
+ const hashmarkIndex = url.indexOf("#");
1035
1040
 
1036
- if (serializerParams) {
1037
- url += (url.indexOf('?') === -1 ? '?' : '&') + serializerParams;
1041
+ if (hashmarkIndex !== -1) {
1042
+ url = url.slice(0, hashmarkIndex);
1043
+ }
1044
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
1038
1045
  }
1039
1046
 
1040
1047
  return url;
@@ -1525,7 +1532,7 @@ function normalizeValue(value) {
1525
1532
  return value;
1526
1533
  }
1527
1534
 
1528
- return String(value);
1535
+ return utils.isArray(value) ? value.map(normalizeValue) : String(value);
1529
1536
  }
1530
1537
 
1531
1538
  function parseTokens(str) {
@@ -1612,13 +1619,7 @@ Object.assign(AxiosHeaders.prototype, {
1612
1619
  return;
1613
1620
  }
1614
1621
 
1615
- if (utils.isArray(_value)) {
1616
- _value = _value.map(normalizeValue);
1617
- } else {
1618
- _value = normalizeValue(_value);
1619
- }
1620
-
1621
- self[key || _header] = _value;
1622
+ self[key || _header] = normalizeValue(_value);
1622
1623
  }
1623
1624
 
1624
1625
  if (utils.isPlainObject(header)) {
@@ -1732,13 +1733,13 @@ Object.assign(AxiosHeaders.prototype, {
1732
1733
  return this;
1733
1734
  },
1734
1735
 
1735
- toJSON: function() {
1736
+ toJSON: function(asStrings) {
1736
1737
  const obj = Object.create(null);
1737
1738
 
1738
1739
  utils.forEach(Object.assign({}, this[$defaults] || null, this),
1739
1740
  (value, header) => {
1740
1741
  if (value == null || value === false) return;
1741
- obj[header] = utils.isArray(value) ? value.join(', ') : value;
1742
+ obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value;
1742
1743
  });
1743
1744
 
1744
1745
  return obj;
@@ -2461,7 +2462,7 @@ function mergeConfig(config1, config2) {
2461
2462
  return config;
2462
2463
  }
2463
2464
 
2464
- const VERSION = "1.1.1";
2465
+ const VERSION = "1.1.3";
2465
2466
 
2466
2467
  const validators$1 = {};
2467
2468
 
@@ -2588,7 +2589,7 @@ class Axios {
2588
2589
 
2589
2590
  config = mergeConfig(this.defaults, config);
2590
2591
 
2591
- const transitional = config.transitional;
2592
+ const {transitional, paramsSerializer} = config;
2592
2593
 
2593
2594
  if (transitional !== undefined) {
2594
2595
  validator.assertOptions(transitional, {
@@ -2598,6 +2599,13 @@ class Axios {
2598
2599
  }, false);
2599
2600
  }
2600
2601
 
2602
+ if (paramsSerializer !== undefined) {
2603
+ validator.assertOptions(paramsSerializer, {
2604
+ encode: validators.function,
2605
+ serialize: validators.function
2606
+ }, true);
2607
+ }
2608
+
2601
2609
  // Set config.method
2602
2610
  config.method = (config.method || this.defaults.method || 'get').toLowerCase();
2603
2611