axios 1.16.0 → 1.16.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.
- package/CHANGELOG.md +71 -0
- package/README.md +46 -11
- package/dist/axios.js +81 -53
- package/dist/axios.js.map +1 -1
- package/dist/axios.min.js +2 -2
- package/dist/axios.min.js.map +1 -1
- package/dist/browser/axios.cjs +96 -64
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +96 -64
- package/dist/esm/axios.js.map +1 -1
- package/dist/esm/axios.min.js +2 -2
- package/dist/esm/axios.min.js.map +1 -1
- package/dist/node/axios.cjs +206 -85
- package/dist/node/axios.cjs.map +1 -1
- package/index.d.cts +1 -1
- package/index.d.ts +1 -1
- package/lib/adapters/fetch.js +6 -2
- package/lib/adapters/http.js +139 -29
- package/lib/adapters/xhr.js +2 -1
- package/lib/core/AxiosHeaders.js +1 -33
- package/lib/env/data.js +1 -1
- package/lib/helpers/composeSignals.js +48 -47
- package/lib/helpers/formDataToJSON.js +1 -1
- package/lib/helpers/fromDataURI.js +18 -5
- package/lib/helpers/progressEventReducer.js +3 -0
- package/lib/helpers/sanitizeHeaderValue.js +60 -0
- package/lib/utils.js +8 -7
- package/package.json +3 -1
package/dist/esm/axios.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Axios v1.16.
|
|
1
|
+
/*! Axios v1.16.1 Copyright (c) 2026 Matt Zabriskie and contributors */
|
|
2
2
|
/**
|
|
3
3
|
* Create a bound version of a function with a specified `this` context
|
|
4
4
|
*
|
|
@@ -773,11 +773,11 @@ function isSpecCompliantForm(thing) {
|
|
|
773
773
|
* @returns {Object} The JSON-compatible object.
|
|
774
774
|
*/
|
|
775
775
|
const toJSONObject = (obj) => {
|
|
776
|
-
const
|
|
776
|
+
const visited = new WeakSet();
|
|
777
777
|
|
|
778
|
-
const visit = (source
|
|
778
|
+
const visit = (source) => {
|
|
779
779
|
if (isObject(source)) {
|
|
780
|
-
if (
|
|
780
|
+
if (visited.has(source)) {
|
|
781
781
|
return;
|
|
782
782
|
}
|
|
783
783
|
|
|
@@ -787,15 +787,16 @@ const toJSONObject = (obj) => {
|
|
|
787
787
|
}
|
|
788
788
|
|
|
789
789
|
if (!('toJSON' in source)) {
|
|
790
|
-
|
|
790
|
+
// add-on descent / delete-on-ascent: preserves path semantics, so DAG nodes serialise at every occurrence (see #7230).
|
|
791
|
+
visited.add(source);
|
|
791
792
|
const target = isArray(source) ? [] : {};
|
|
792
793
|
|
|
793
794
|
forEach(source, (value, key) => {
|
|
794
|
-
const reducedValue = visit(value
|
|
795
|
+
const reducedValue = visit(value);
|
|
795
796
|
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
|
796
797
|
});
|
|
797
798
|
|
|
798
|
-
|
|
799
|
+
visited.delete(source);
|
|
799
800
|
|
|
800
801
|
return target;
|
|
801
802
|
}
|
|
@@ -804,7 +805,7 @@ const toJSONObject = (obj) => {
|
|
|
804
805
|
return source;
|
|
805
806
|
};
|
|
806
807
|
|
|
807
|
-
return visit(obj
|
|
808
|
+
return visit(obj);
|
|
808
809
|
};
|
|
809
810
|
|
|
810
811
|
/**
|
|
@@ -1006,10 +1007,6 @@ var parseHeaders = (rawHeaders) => {
|
|
|
1006
1007
|
return parsed;
|
|
1007
1008
|
};
|
|
1008
1009
|
|
|
1009
|
-
const $internals = Symbol('internals');
|
|
1010
|
-
|
|
1011
|
-
const INVALID_HEADER_VALUE_CHARS_RE = /[^\x09\x20-\x7E\x80-\xFF]/g;
|
|
1012
|
-
|
|
1013
1010
|
function trimSPorHTAB(str) {
|
|
1014
1011
|
let start = 0;
|
|
1015
1012
|
let end = str.length;
|
|
@@ -1037,12 +1034,40 @@ function trimSPorHTAB(str) {
|
|
|
1037
1034
|
return start === 0 && end === str.length ? str : str.slice(start, end);
|
|
1038
1035
|
}
|
|
1039
1036
|
|
|
1040
|
-
|
|
1041
|
-
|
|
1037
|
+
// The control-code ranges are intentional: header sanitization strips C0/DEL bytes.
|
|
1038
|
+
// eslint-disable-next-line no-control-regex
|
|
1039
|
+
const INVALID_UNICODE_HEADER_VALUE_CHARS = new RegExp('[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+', 'g');
|
|
1040
|
+
// eslint-disable-next-line no-control-regex
|
|
1041
|
+
const INVALID_BYTE_STRING_HEADER_VALUE_CHARS = new RegExp('[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+', 'g');
|
|
1042
|
+
|
|
1043
|
+
function sanitizeValue(value, invalidChars) {
|
|
1044
|
+
if (utils$1.isArray(value)) {
|
|
1045
|
+
return value.map((item) => sanitizeValue(item, invalidChars));
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
return trimSPorHTAB(String(value).replace(invalidChars, ''));
|
|
1042
1049
|
}
|
|
1043
1050
|
|
|
1044
|
-
|
|
1045
|
-
|
|
1051
|
+
const sanitizeHeaderValue = (value) =>
|
|
1052
|
+
sanitizeValue(value, INVALID_UNICODE_HEADER_VALUE_CHARS);
|
|
1053
|
+
|
|
1054
|
+
const sanitizeByteStringHeaderValue = (value) =>
|
|
1055
|
+
sanitizeValue(value, INVALID_BYTE_STRING_HEADER_VALUE_CHARS);
|
|
1056
|
+
|
|
1057
|
+
function toByteStringHeaderObject(headers) {
|
|
1058
|
+
const byteStringHeaders = Object.create(null);
|
|
1059
|
+
|
|
1060
|
+
utils$1.forEach(headers.toJSON(), (value, header) => {
|
|
1061
|
+
byteStringHeaders[header] = sanitizeByteStringHeaderValue(value);
|
|
1062
|
+
});
|
|
1063
|
+
|
|
1064
|
+
return byteStringHeaders;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
const $internals = Symbol('internals');
|
|
1068
|
+
|
|
1069
|
+
function normalizeHeader(header) {
|
|
1070
|
+
return header && String(header).trim().toLowerCase();
|
|
1046
1071
|
}
|
|
1047
1072
|
|
|
1048
1073
|
function normalizeValue(value) {
|
|
@@ -2141,7 +2166,7 @@ function formDataToJSON(formData) {
|
|
|
2141
2166
|
return !isNumericKey;
|
|
2142
2167
|
}
|
|
2143
2168
|
|
|
2144
|
-
if (!target
|
|
2169
|
+
if (!utils$1.hasOwnProp(target, name) || !utils$1.isObject(target[name])) {
|
|
2145
2170
|
target[name] = [];
|
|
2146
2171
|
}
|
|
2147
2172
|
|
|
@@ -2506,6 +2531,9 @@ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
|
2506
2531
|
const _speedometer = speedometer(50, 250);
|
|
2507
2532
|
|
|
2508
2533
|
return throttle((e) => {
|
|
2534
|
+
if (!e || typeof e.loaded !== 'number') {
|
|
2535
|
+
return;
|
|
2536
|
+
}
|
|
2509
2537
|
const rawLoaded = e.loaded;
|
|
2510
2538
|
const total = e.lengthComputable ? e.total : undefined;
|
|
2511
2539
|
const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
|
|
@@ -3037,7 +3065,7 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3037
3065
|
|
|
3038
3066
|
// Add headers to the request
|
|
3039
3067
|
if ('setRequestHeader' in request) {
|
|
3040
|
-
utils$1.forEach(requestHeaders
|
|
3068
|
+
utils$1.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
|
|
3041
3069
|
request.setRequestHeader(key, val);
|
|
3042
3070
|
});
|
|
3043
3071
|
}
|
|
@@ -3107,54 +3135,55 @@ var xhrAdapter = isXHRAdapterSupported &&
|
|
|
3107
3135
|
};
|
|
3108
3136
|
|
|
3109
3137
|
const composeSignals = (signals, timeout) => {
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
if (timeout || length) {
|
|
3113
|
-
let controller = new AbortController();
|
|
3114
|
-
|
|
3115
|
-
let aborted;
|
|
3116
|
-
|
|
3117
|
-
const onabort = function (reason) {
|
|
3118
|
-
if (!aborted) {
|
|
3119
|
-
aborted = true;
|
|
3120
|
-
unsubscribe();
|
|
3121
|
-
const err = reason instanceof Error ? reason : this.reason;
|
|
3122
|
-
controller.abort(
|
|
3123
|
-
err instanceof AxiosError$1
|
|
3124
|
-
? err
|
|
3125
|
-
: new CanceledError$1(err instanceof Error ? err.message : err)
|
|
3126
|
-
);
|
|
3127
|
-
}
|
|
3128
|
-
};
|
|
3138
|
+
signals = signals ? signals.filter(Boolean) : [];
|
|
3129
3139
|
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
}, timeout);
|
|
3136
|
-
|
|
3137
|
-
const unsubscribe = () => {
|
|
3138
|
-
if (signals) {
|
|
3139
|
-
timer && clearTimeout(timer);
|
|
3140
|
-
timer = null;
|
|
3141
|
-
signals.forEach((signal) => {
|
|
3142
|
-
signal.unsubscribe
|
|
3143
|
-
? signal.unsubscribe(onabort)
|
|
3144
|
-
: signal.removeEventListener('abort', onabort);
|
|
3145
|
-
});
|
|
3146
|
-
signals = null;
|
|
3147
|
-
}
|
|
3148
|
-
};
|
|
3140
|
+
if (!timeout && !signals.length) {
|
|
3141
|
+
return;
|
|
3142
|
+
}
|
|
3143
|
+
|
|
3144
|
+
const controller = new AbortController();
|
|
3149
3145
|
|
|
3150
|
-
|
|
3146
|
+
let aborted = false;
|
|
3151
3147
|
|
|
3152
|
-
|
|
3148
|
+
const onabort = function (reason) {
|
|
3149
|
+
if (!aborted) {
|
|
3150
|
+
aborted = true;
|
|
3151
|
+
unsubscribe();
|
|
3152
|
+
const err = reason instanceof Error ? reason : this.reason;
|
|
3153
|
+
controller.abort(
|
|
3154
|
+
err instanceof AxiosError$1
|
|
3155
|
+
? err
|
|
3156
|
+
: new CanceledError$1(err instanceof Error ? err.message : err)
|
|
3157
|
+
);
|
|
3158
|
+
}
|
|
3159
|
+
};
|
|
3160
|
+
|
|
3161
|
+
let timer =
|
|
3162
|
+
timeout &&
|
|
3163
|
+
setTimeout(() => {
|
|
3164
|
+
timer = null;
|
|
3165
|
+
onabort(new AxiosError$1(`timeout of ${timeout}ms exceeded`, AxiosError$1.ETIMEDOUT));
|
|
3166
|
+
}, timeout);
|
|
3167
|
+
|
|
3168
|
+
const unsubscribe = () => {
|
|
3169
|
+
if (!signals) { return; }
|
|
3170
|
+
timer && clearTimeout(timer);
|
|
3171
|
+
timer = null;
|
|
3172
|
+
signals.forEach((signal) => {
|
|
3173
|
+
signal.unsubscribe
|
|
3174
|
+
? signal.unsubscribe(onabort)
|
|
3175
|
+
: signal.removeEventListener('abort', onabort);
|
|
3176
|
+
});
|
|
3177
|
+
signals = null;
|
|
3178
|
+
};
|
|
3153
3179
|
|
|
3154
|
-
|
|
3180
|
+
signals.forEach((signal) => signal.addEventListener('abort', onabort));
|
|
3155
3181
|
|
|
3156
|
-
|
|
3157
|
-
|
|
3182
|
+
const { signal } = controller;
|
|
3183
|
+
|
|
3184
|
+
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
3185
|
+
|
|
3186
|
+
return signal;
|
|
3158
3187
|
};
|
|
3159
3188
|
|
|
3160
3189
|
const streamChunk = function* (chunk, chunkSize) {
|
|
@@ -3348,7 +3377,7 @@ function estimateDataURLDecodedBytes(url) {
|
|
|
3348
3377
|
return bytes;
|
|
3349
3378
|
}
|
|
3350
3379
|
|
|
3351
|
-
const VERSION$1 = "1.16.
|
|
3380
|
+
const VERSION$1 = "1.16.1";
|
|
3352
3381
|
|
|
3353
3382
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
3354
3383
|
|
|
@@ -3363,7 +3392,10 @@ const test = (fn, ...args) => {
|
|
|
3363
3392
|
};
|
|
3364
3393
|
|
|
3365
3394
|
const factory = (env) => {
|
|
3366
|
-
const globalObject =
|
|
3395
|
+
const globalObject =
|
|
3396
|
+
utils$1.global !== undefined && utils$1.global !== null
|
|
3397
|
+
? utils$1.global
|
|
3398
|
+
: globalThis;
|
|
3367
3399
|
const { ReadableStream, TextEncoder } = globalObject;
|
|
3368
3400
|
|
|
3369
3401
|
env = utils$1.merge.call(
|
|
@@ -3620,7 +3652,7 @@ const factory = (env) => {
|
|
|
3620
3652
|
...fetchOptions,
|
|
3621
3653
|
signal: composedSignal,
|
|
3622
3654
|
method: method.toUpperCase(),
|
|
3623
|
-
headers: headers.normalize()
|
|
3655
|
+
headers: toByteStringHeaderObject(headers.normalize()),
|
|
3624
3656
|
body: data,
|
|
3625
3657
|
duplex: 'half',
|
|
3626
3658
|
credentials: isCredentialsSupported ? withCredentials : undefined,
|