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 +30 -0
- package/dist/axios.js +52 -26
- 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 +57 -27
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +57 -27
- 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 +241 -24
- 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 +41 -5
- package/lib/core/AxiosHeaders.js +15 -3
- 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 +5 -15
- package/lib/utils.js +35 -1
- package/package.json +7 -4
package/dist/browser/axios.cjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.
|
1
|
+
// Axios v1.3.1 Copyright (c) 2023 Matt Zabriskie and contributors
|
2
2
|
'use strict';
|
3
3
|
|
4
4
|
function bind(fn, thisArg) {
|
@@ -517,7 +517,7 @@ const matchAll = (regExp, str) => {
|
|
517
517
|
const isHTMLForm = kindOfTest('HTMLFormElement');
|
518
518
|
|
519
519
|
const toCamelCase = str => {
|
520
|
-
return str.toLowerCase().replace(/[_
|
520
|
+
return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
|
521
521
|
function replacer(m, p1, p2) {
|
522
522
|
return p1.toUpperCase() + p2;
|
523
523
|
}
|
@@ -601,6 +601,37 @@ const toFiniteNumber = (value, defaultValue) => {
|
|
601
601
|
return Number.isFinite(value) ? value : defaultValue;
|
602
602
|
};
|
603
603
|
|
604
|
+
const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
|
605
|
+
|
606
|
+
const DIGIT = '0123456789';
|
607
|
+
|
608
|
+
const ALPHABET = {
|
609
|
+
DIGIT,
|
610
|
+
ALPHA,
|
611
|
+
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
|
612
|
+
};
|
613
|
+
|
614
|
+
const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
|
615
|
+
let str = '';
|
616
|
+
const {length} = alphabet;
|
617
|
+
while (size--) {
|
618
|
+
str += alphabet[Math.random() * length|0];
|
619
|
+
}
|
620
|
+
|
621
|
+
return str;
|
622
|
+
};
|
623
|
+
|
624
|
+
/**
|
625
|
+
* If the thing is a FormData object, return true, otherwise return false.
|
626
|
+
*
|
627
|
+
* @param {unknown} thing - The thing to check.
|
628
|
+
*
|
629
|
+
* @returns {boolean}
|
630
|
+
*/
|
631
|
+
function isSpecCompliantForm(thing) {
|
632
|
+
return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
|
633
|
+
}
|
634
|
+
|
604
635
|
const toJSONObject = (obj) => {
|
605
636
|
const stack = new Array(10);
|
606
637
|
|
@@ -678,6 +709,9 @@ var utils = {
|
|
678
709
|
findKey,
|
679
710
|
global: _global,
|
680
711
|
isContextDefined,
|
712
|
+
ALPHABET,
|
713
|
+
generateString,
|
714
|
+
isSpecCompliantForm,
|
681
715
|
toJSONObject
|
682
716
|
};
|
683
717
|
|
@@ -776,10 +810,8 @@ AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
776
810
|
return axiosError;
|
777
811
|
};
|
778
812
|
|
779
|
-
|
780
|
-
var
|
781
|
-
|
782
|
-
var FormData$2 = browser;
|
813
|
+
// eslint-disable-next-line strict
|
814
|
+
var httpAdapter = null;
|
783
815
|
|
784
816
|
/**
|
785
817
|
* Determines if the given thing is a array or js object.
|
@@ -836,17 +868,6 @@ const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
|
|
836
868
|
return /^is[A-Z]/.test(prop);
|
837
869
|
});
|
838
870
|
|
839
|
-
/**
|
840
|
-
* If the thing is a FormData object, return true, otherwise return false.
|
841
|
-
*
|
842
|
-
* @param {unknown} thing - The thing to check.
|
843
|
-
*
|
844
|
-
* @returns {boolean}
|
845
|
-
*/
|
846
|
-
function isSpecCompliant(thing) {
|
847
|
-
return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
|
848
|
-
}
|
849
|
-
|
850
871
|
/**
|
851
872
|
* Convert a data object to FormData
|
852
873
|
*
|
@@ -876,7 +897,7 @@ function toFormData(obj, formData, options) {
|
|
876
897
|
}
|
877
898
|
|
878
899
|
// eslint-disable-next-line no-param-reassign
|
879
|
-
formData = formData || new (FormData
|
900
|
+
formData = formData || new (FormData)();
|
880
901
|
|
881
902
|
// eslint-disable-next-line no-param-reassign
|
882
903
|
options = utils.toFlatObject(options, {
|
@@ -894,7 +915,7 @@ function toFormData(obj, formData, options) {
|
|
894
915
|
const dots = options.dots;
|
895
916
|
const indexes = options.indexes;
|
896
917
|
const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
|
897
|
-
const useBlob = _Blob &&
|
918
|
+
const useBlob = _Blob && utils.isSpecCompliantForm(formData);
|
898
919
|
|
899
920
|
if (!utils.isFunction(visitor)) {
|
900
921
|
throw new TypeError('visitor must be a function');
|
@@ -939,7 +960,7 @@ function toFormData(obj, formData, options) {
|
|
939
960
|
value = JSON.stringify(value);
|
940
961
|
} else if (
|
941
962
|
(utils.isArray(value) && isFlatArray(value)) ||
|
942
|
-
(utils.isFileList(value) || utils.endsWith(key, '[]') && (arr = utils.toArray(value))
|
963
|
+
((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))
|
943
964
|
)) {
|
944
965
|
// eslint-disable-next-line no-param-reassign
|
945
966
|
key = removeBrackets(key);
|
@@ -1701,7 +1722,7 @@ class AxiosHeaders {
|
|
1701
1722
|
if (header) {
|
1702
1723
|
const key = utils.findKey(this, header);
|
1703
1724
|
|
1704
|
-
return !!(key && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
1725
|
+
return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
1705
1726
|
}
|
1706
1727
|
|
1707
1728
|
return false;
|
@@ -1734,8 +1755,20 @@ class AxiosHeaders {
|
|
1734
1755
|
return deleted;
|
1735
1756
|
}
|
1736
1757
|
|
1737
|
-
clear() {
|
1738
|
-
|
1758
|
+
clear(matcher) {
|
1759
|
+
const keys = Object.keys(this);
|
1760
|
+
let i = keys.length;
|
1761
|
+
let deleted = false;
|
1762
|
+
|
1763
|
+
while (i--) {
|
1764
|
+
const key = keys[i];
|
1765
|
+
if(!matcher || matchHeaderValue(this, this[key], key, matcher)) {
|
1766
|
+
delete this[key];
|
1767
|
+
deleted = true;
|
1768
|
+
}
|
1769
|
+
}
|
1770
|
+
|
1771
|
+
return deleted;
|
1739
1772
|
}
|
1740
1773
|
|
1741
1774
|
normalize(format) {
|
@@ -1879,9 +1912,6 @@ utils.inherits(CanceledError, AxiosError, {
|
|
1879
1912
|
__CANCEL__: true
|
1880
1913
|
});
|
1881
1914
|
|
1882
|
-
// eslint-disable-next-line strict
|
1883
|
-
var httpAdapter = null;
|
1884
|
-
|
1885
1915
|
/**
|
1886
1916
|
* Resolve or reject a Promise based on response status.
|
1887
1917
|
*
|
@@ -2582,7 +2612,7 @@ function mergeConfig(config1, config2) {
|
|
2582
2612
|
return config;
|
2583
2613
|
}
|
2584
2614
|
|
2585
|
-
const VERSION = "1.
|
2615
|
+
const VERSION = "1.3.1";
|
2586
2616
|
|
2587
2617
|
const validators$1 = {};
|
2588
2618
|
|