axios 1.2.6 → 1.3.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.
Potentially problematic release.
This version of axios might be problematic. Click here for more details.
- package/CHANGELOG.md +18 -0
- package/dist/axios.js +50 -24
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +1 -1
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +55 -25
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +55 -25
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +1 -1
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +229 -20
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +1 -1
- package/index.d.ts +1 -1
- package/lib/adapters/http.js +32 -3
- package/lib/core/AxiosHeaders.js +14 -2
- package/lib/env/classes/FormData.js +2 -2
- package/lib/env/data.js +1 -1
- package/lib/helpers/ZlibHeaderTransformStream.js +28 -0
- package/lib/helpers/formDataToStream.js +110 -0
- package/lib/helpers/readBlob.js +15 -0
- package/lib/helpers/toFormData.js +4 -14
- package/lib/utils.js +35 -1
- package/package.json +7 -4
package/dist/esm/axios.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.
|
1
|
+
// Axios v1.3.0 Copyright (c) 2023 Matt Zabriskie and contributors
|
2
2
|
function bind(fn, thisArg) {
|
3
3
|
return function wrap() {
|
4
4
|
return fn.apply(thisArg, arguments);
|
@@ -515,7 +515,7 @@ const matchAll = (regExp, str) => {
|
|
515
515
|
const isHTMLForm = kindOfTest('HTMLFormElement');
|
516
516
|
|
517
517
|
const toCamelCase = str => {
|
518
|
-
return str.toLowerCase().replace(/[_
|
518
|
+
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
|
519
519
|
function replacer(m, p1, p2) {
|
520
520
|
return p1.toUpperCase() + p2;
|
521
521
|
}
|
@@ -599,6 +599,37 @@ const toFiniteNumber = (value, defaultValue) => {
|
|
599
599
|
return Number.isFinite(value) ? value : defaultValue;
|
600
600
|
};
|
601
601
|
|
602
|
+
const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
|
603
|
+
|
604
|
+
const DIGIT = '0123456789';
|
605
|
+
|
606
|
+
const ALPHABET = {
|
607
|
+
DIGIT,
|
608
|
+
ALPHA,
|
609
|
+
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
|
610
|
+
};
|
611
|
+
|
612
|
+
const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
|
613
|
+
let str = '';
|
614
|
+
const {length} = alphabet;
|
615
|
+
while (size--) {
|
616
|
+
str += alphabet[Math.random() * length|0];
|
617
|
+
}
|
618
|
+
|
619
|
+
return str;
|
620
|
+
};
|
621
|
+
|
622
|
+
/**
|
623
|
+
* If the thing is a FormData object, return true, otherwise return false.
|
624
|
+
*
|
625
|
+
* @param {unknown} thing - The thing to check.
|
626
|
+
*
|
627
|
+
* @returns {boolean}
|
628
|
+
*/
|
629
|
+
function isSpecCompliantForm(thing) {
|
630
|
+
return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
|
631
|
+
}
|
632
|
+
|
602
633
|
const toJSONObject = (obj) => {
|
603
634
|
const stack = new Array(10);
|
604
635
|
|
@@ -676,6 +707,9 @@ const utils = {
|
|
676
707
|
findKey,
|
677
708
|
global: _global,
|
678
709
|
isContextDefined,
|
710
|
+
ALPHABET,
|
711
|
+
generateString,
|
712
|
+
isSpecCompliantForm,
|
679
713
|
toJSONObject
|
680
714
|
};
|
681
715
|
|
@@ -774,10 +808,8 @@ AxiosError$1.from = (error, code, config, request, response, customProps) => {
|
|
774
808
|
return axiosError;
|
775
809
|
};
|
776
810
|
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
const FormData$2 = browser;
|
811
|
+
// eslint-disable-next-line strict
|
812
|
+
const httpAdapter = null;
|
781
813
|
|
782
814
|
/**
|
783
815
|
* Determines if the given thing is a array or js object.
|
@@ -834,17 +866,6 @@ const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
|
|
834
866
|
return /^is[A-Z]/.test(prop);
|
835
867
|
});
|
836
868
|
|
837
|
-
/**
|
838
|
-
* If the thing is a FormData object, return true, otherwise return false.
|
839
|
-
*
|
840
|
-
* @param {unknown} thing - The thing to check.
|
841
|
-
*
|
842
|
-
* @returns {boolean}
|
843
|
-
*/
|
844
|
-
function isSpecCompliant(thing) {
|
845
|
-
return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
|
846
|
-
}
|
847
|
-
|
848
869
|
/**
|
849
870
|
* Convert a data object to FormData
|
850
871
|
*
|
@@ -874,7 +895,7 @@ function toFormData$1(obj, formData, options) {
|
|
874
895
|
}
|
875
896
|
|
876
897
|
// eslint-disable-next-line no-param-reassign
|
877
|
-
formData = formData || new (FormData
|
898
|
+
formData = formData || new (FormData)();
|
878
899
|
|
879
900
|
// eslint-disable-next-line no-param-reassign
|
880
901
|
options = utils.toFlatObject(options, {
|
@@ -892,7 +913,7 @@ function toFormData$1(obj, formData, options) {
|
|
892
913
|
const dots = options.dots;
|
893
914
|
const indexes = options.indexes;
|
894
915
|
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
895
|
-
const useBlob = _Blob &&
|
916
|
+
const useBlob = _Blob && utils.isSpecCompliantForm(formData);
|
896
917
|
|
897
918
|
if (!utils.isFunction(visitor)) {
|
898
919
|
throw new TypeError('visitor must be a function');
|
@@ -1732,8 +1753,20 @@ class AxiosHeaders$1 {
|
|
1732
1753
|
return deleted;
|
1733
1754
|
}
|
1734
1755
|
|
1735
|
-
clear() {
|
1736
|
-
|
1756
|
+
clear(matcher) {
|
1757
|
+
const keys = Object.keys(this);
|
1758
|
+
let i = keys.length;
|
1759
|
+
let deleted = false;
|
1760
|
+
|
1761
|
+
while (i--) {
|
1762
|
+
const key = keys[i];
|
1763
|
+
if(!matcher || matchHeaderValue(this, this[key], key, matcher)) {
|
1764
|
+
delete this[key];
|
1765
|
+
deleted = true;
|
1766
|
+
}
|
1767
|
+
}
|
1768
|
+
|
1769
|
+
return deleted;
|
1737
1770
|
}
|
1738
1771
|
|
1739
1772
|
normalize(format) {
|
@@ -1877,9 +1910,6 @@ utils.inherits(CanceledError$1, AxiosError$1, {
|
|
1877
1910
|
__CANCEL__: true
|
1878
1911
|
});
|
1879
1912
|
|
1880
|
-
// eslint-disable-next-line strict
|
1881
|
-
const httpAdapter = null;
|
1882
|
-
|
1883
1913
|
/**
|
1884
1914
|
* Resolve or reject a Promise based on response status.
|
1885
1915
|
*
|
@@ -2580,7 +2610,7 @@ function mergeConfig$1(config1, config2) {
|
|
2580
2610
|
return config;
|
2581
2611
|
}
|
2582
2612
|
|
2583
|
-
const VERSION$1 = "1.
|
2613
|
+
const VERSION$1 = "1.3.0";
|
2584
2614
|
|
2585
2615
|
const validators$1 = {};
|
2586
2616
|
|