axios 1.2.6 → 1.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.3.1](https://github.com/axios/axios/compare/v1.3.0...v1.3.1) (2023-02-01)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **formdata:** add hotfix to use the asynchronous API to compute the content-length header value; ([#5521](https://github.com/axios/axios/issues/5521)) ([96d336f](https://github.com/axios/axios/commit/96d336f527619f21da012fe1f117eeb53e5a2120))
9
+ * **serializer:** fixed serialization of array-like objects; ([#5518](https://github.com/axios/axios/issues/5518)) ([08104c0](https://github.com/axios/axios/commit/08104c028c0f9353897b1b6691d74c440fd0c32d))
10
+
11
+ ### Contributors to this release
12
+
13
+ - <img src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+27/-8 (#5521 #5518 )")
14
+
15
+ # [1.3.0](https://github.com/axios/axios/compare/v1.2.6...v1.3.0) (2023-01-31)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **headers:** fixed & optimized clear method; ([#5507](https://github.com/axios/axios/issues/5507)) ([9915635](https://github.com/axios/axios/commit/9915635c69d0ab70daca5738488421f67ca60959))
21
+ * **http:** add zlib headers if missing ([#5497](https://github.com/axios/axios/issues/5497)) ([65e8d1e](https://github.com/axios/axios/commit/65e8d1e28ce829f47a837e45129730e541950d3c))
22
+
23
+
24
+ ### Features
25
+
26
+ * **fomdata:** added support for spec-compliant FormData & Blob types; ([#5316](https://github.com/axios/axios/issues/5316)) ([6ac574e](https://github.com/axios/axios/commit/6ac574e00a06731288347acea1e8246091196953))
27
+
28
+ ### Contributors to this release
29
+
30
+ - <img src="https://avatars.githubusercontent.com/u/12586868?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+352/-67 (#5514 #5512 #5510 #5509 #5508 #5316 #5507 )")
31
+ - <img src="https://avatars.githubusercontent.com/u/35015993?v&#x3D;4&amp;s&#x3D;18" alt="avatar" width="18"/> [ItsNotGoodName](https://github.com/ItsNotGoodName "+43/-2 (#5497 )")
32
+
3
33
  ## [1.2.6](https://github.com/axios/axios/compare/v1.2.5...v1.2.6) (2023-01-28)
4
34
 
5
35
 
package/dist/axios.js CHANGED
@@ -1,4 +1,4 @@
1
- // Axios v1.2.6 Copyright (c) 2023 Matt Zabriskie and contributors
1
+ // Axios v1.3.1 Copyright (c) 2023 Matt Zabriskie and contributors
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) :
@@ -598,7 +598,7 @@
598
598
  /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
599
599
  var isHTMLForm = kindOfTest('HTMLFormElement');
600
600
  var toCamelCase = function toCamelCase(str) {
601
- return str.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
601
+ return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
602
602
  return p1.toUpperCase() + p2;
603
603
  });
604
604
  };
@@ -670,6 +670,34 @@
670
670
  value = +value;
671
671
  return Number.isFinite(value) ? value : defaultValue;
672
672
  };
673
+ var ALPHA = 'abcdefghijklmnopqrstuvwxyz';
674
+ var DIGIT = '0123456789';
675
+ var ALPHABET = {
676
+ DIGIT: DIGIT,
677
+ ALPHA: ALPHA,
678
+ ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
679
+ };
680
+ var generateString = function generateString() {
681
+ var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 16;
682
+ var alphabet = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ALPHABET.ALPHA_DIGIT;
683
+ var str = '';
684
+ var length = alphabet.length;
685
+ while (size--) {
686
+ str += alphabet[Math.random() * length | 0];
687
+ }
688
+ return str;
689
+ };
690
+
691
+ /**
692
+ * If the thing is a FormData object, return true, otherwise return false.
693
+ *
694
+ * @param {unknown} thing - The thing to check.
695
+ *
696
+ * @returns {boolean}
697
+ */
698
+ function isSpecCompliantForm(thing) {
699
+ return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
700
+ }
673
701
  var toJSONObject = function toJSONObject(obj) {
674
702
  var stack = new Array(10);
675
703
  var visit = function visit(source, i) {
@@ -739,6 +767,9 @@
739
767
  findKey: findKey,
740
768
  global: _global,
741
769
  isContextDefined: isContextDefined,
770
+ ALPHABET: ALPHABET,
771
+ generateString: generateString,
772
+ isSpecCompliantForm: isSpecCompliantForm,
742
773
  toJSONObject: toJSONObject
743
774
  };
744
775
 
@@ -817,9 +848,8 @@
817
848
  return axiosError;
818
849
  };
819
850
 
820
- /* eslint-env browser */
821
- var browser = (typeof self === "undefined" ? "undefined" : _typeof(self)) == 'object' ? self.FormData : window.FormData;
822
- var FormData$2 = browser;
851
+ // eslint-disable-next-line strict
852
+ var httpAdapter = null;
823
853
 
824
854
  /**
825
855
  * Determines if the given thing is a array or js object.
@@ -875,17 +905,6 @@
875
905
  return /^is[A-Z]/.test(prop);
876
906
  });
877
907
 
878
- /**
879
- * If the thing is a FormData object, return true, otherwise return false.
880
- *
881
- * @param {unknown} thing - The thing to check.
882
- *
883
- * @returns {boolean}
884
- */
885
- function isSpecCompliant(thing) {
886
- return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
887
- }
888
-
889
908
  /**
890
909
  * Convert a data object to FormData
891
910
  *
@@ -915,7 +934,7 @@
915
934
  }
916
935
 
917
936
  // eslint-disable-next-line no-param-reassign
918
- formData = formData || new (FormData$2 || FormData)();
937
+ formData = formData || new (FormData)();
919
938
 
920
939
  // eslint-disable-next-line no-param-reassign
921
940
  options = utils.toFlatObject(options, {
@@ -932,7 +951,7 @@
932
951
  var dots = options.dots;
933
952
  var indexes = options.indexes;
934
953
  var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
935
- var useBlob = _Blob && isSpecCompliant(formData);
954
+ var useBlob = _Blob && utils.isSpecCompliantForm(formData);
936
955
  if (!utils.isFunction(visitor)) {
937
956
  throw new TypeError('visitor must be a function');
938
957
  }
@@ -968,7 +987,7 @@
968
987
  key = metaTokens ? key : key.slice(0, -2);
969
988
  // eslint-disable-next-line no-param-reassign
970
989
  value = JSON.stringify(value);
971
- } else if (utils.isArray(value) && isFlatArray(value) || utils.isFileList(value) || utils.endsWith(key, '[]') && (arr = utils.toArray(value))) {
990
+ } else if (utils.isArray(value) && isFlatArray(value) || (utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))) {
972
991
  // eslint-disable-next-line no-param-reassign
973
992
  key = removeBrackets(key);
974
993
  arr.forEach(function each(el, index) {
@@ -1610,7 +1629,7 @@
1610
1629
  header = normalizeHeader(header);
1611
1630
  if (header) {
1612
1631
  var key = utils.findKey(this, header);
1613
- return !!(key && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1632
+ return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1614
1633
  }
1615
1634
  return false;
1616
1635
  }
@@ -1638,8 +1657,18 @@
1638
1657
  }
1639
1658
  }, {
1640
1659
  key: "clear",
1641
- value: function clear() {
1642
- return Object.keys(this).forEach(this["delete"].bind(this));
1660
+ value: function clear(matcher) {
1661
+ var keys = Object.keys(this);
1662
+ var i = keys.length;
1663
+ var deleted = false;
1664
+ while (i--) {
1665
+ var key = keys[i];
1666
+ if (!matcher || matchHeaderValue(this, this[key], key, matcher)) {
1667
+ delete this[key];
1668
+ deleted = true;
1669
+ }
1670
+ }
1671
+ return deleted;
1643
1672
  }
1644
1673
  }, {
1645
1674
  key: "normalize",
@@ -1785,9 +1814,6 @@
1785
1814
  __CANCEL__: true
1786
1815
  });
1787
1816
 
1788
- // eslint-disable-next-line strict
1789
- var httpAdapter = null;
1790
-
1791
1817
  /**
1792
1818
  * Resolve or reject a Promise based on response status.
1793
1819
  *
@@ -2397,7 +2423,7 @@
2397
2423
  return config;
2398
2424
  }
2399
2425
 
2400
- var VERSION = "1.2.6";
2426
+ var VERSION = "1.3.1";
2401
2427
 
2402
2428
  var validators$1 = {};
2403
2429