axios 1.7.0 → 1.7.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 +14 -3
- package/dist/axios.js +94 -68
- 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 +15 -11
- package/dist/browser/axios.cjs.map +1 -1
- package/dist/esm/axios.js +15 -11
- 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 +15 -11
- package/dist/node/axios.cjs.map +1 -1
- package/lib/adapters/fetch.js +9 -3
- package/lib/env/data.js +1 -1
- package/lib/helpers/trackStream.js +5 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [1.7.1](https://github.com/axios/axios/compare/v1.7.0...v1.7.1) (2024-05-20)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* **fetch:** fixed ReferenceError issue when TextEncoder is not available in the environment; ([#6410](https://github.com/axios/axios/issues/6410)) ([733f15f](https://github.com/axios/axios/commit/733f15fe5bd2d67e1fadaee82e7913b70d45dc5e))
|
9
|
+
|
10
|
+
### Contributors to this release
|
11
|
+
|
12
|
+
- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+14/-9 (#6410 )")
|
13
|
+
|
3
14
|
# [1.7.0](https://github.com/axios/axios/compare/v1.7.0-beta.2...v1.7.0) (2024-05-19)
|
4
15
|
|
5
16
|
|
@@ -927,4 +938,4 @@ This functionality is considered as a fix.
|
|
927
938
|
- [Marco Weber](https://github.com/mrcwbr)
|
928
939
|
- [Luca Pizzini](https://github.com/lpizzinidev)
|
929
940
|
- [Willian Agostini](https://github.com/WillianAgostini)
|
930
|
-
- [Huyen Nguyen](https://github.com/huyenltnguyen)
|
941
|
+
- [Huyen Nguyen](https://github.com/huyenltnguyen)
|
package/dist/axios.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// Axios v1.7.
|
1
|
+
// Axios v1.7.1 Copyright (c) 2024 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) :
|
@@ -3085,9 +3085,8 @@
|
|
3085
3085
|
}
|
3086
3086
|
}, streamChunk);
|
3087
3087
|
});
|
3088
|
-
var encoder = new TextEncoder();
|
3089
3088
|
var readBytes = /*#__PURE__*/function () {
|
3090
|
-
var _ref = _wrapAsyncGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(iterable, chunkSize) {
|
3089
|
+
var _ref = _wrapAsyncGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(iterable, chunkSize, encode) {
|
3091
3090
|
var _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, chunk;
|
3092
3091
|
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
3093
3092
|
while (1) switch (_context2.prev = _context2.next) {
|
@@ -3117,7 +3116,7 @@
|
|
3117
3116
|
break;
|
3118
3117
|
case 15:
|
3119
3118
|
_context2.next = 17;
|
3120
|
-
return _awaitAsyncGenerator(
|
3119
|
+
return _awaitAsyncGenerator(encode(String(chunk)));
|
3121
3120
|
case 17:
|
3122
3121
|
_context2.t3 = _context2.sent;
|
3123
3122
|
case 18:
|
@@ -3165,12 +3164,12 @@
|
|
3165
3164
|
}
|
3166
3165
|
}, _callee, null, [[2, 29, 33, 43], [34,, 38, 42]]);
|
3167
3166
|
}));
|
3168
|
-
return function readBytes(_x, _x2) {
|
3167
|
+
return function readBytes(_x, _x2, _x3) {
|
3169
3168
|
return _ref.apply(this, arguments);
|
3170
3169
|
};
|
3171
3170
|
}();
|
3172
|
-
var trackStream = function trackStream(stream, chunkSize, onProgress, onFinish) {
|
3173
|
-
var iterator = readBytes(stream, chunkSize);
|
3171
|
+
var trackStream = function trackStream(stream, chunkSize, onProgress, onFinish, encode) {
|
3172
|
+
var iterator = readBytes(stream, chunkSize, encode);
|
3174
3173
|
var bytes = 0;
|
3175
3174
|
return new ReadableStream({
|
3176
3175
|
type: 'bytes',
|
@@ -3227,6 +3226,33 @@
|
|
3227
3226
|
};
|
3228
3227
|
var isFetchSupported = typeof fetch !== 'undefined';
|
3229
3228
|
var isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== 'undefined';
|
3229
|
+
|
3230
|
+
// used only inside the fetch adapter
|
3231
|
+
var encodeText = isFetchSupported && (typeof TextEncoder !== 'undefined' ? function (encoder) {
|
3232
|
+
return function (str) {
|
3233
|
+
return encoder.encode(str);
|
3234
|
+
};
|
3235
|
+
}(new TextEncoder()) : ( /*#__PURE__*/function () {
|
3236
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(str) {
|
3237
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
3238
|
+
while (1) switch (_context.prev = _context.next) {
|
3239
|
+
case 0:
|
3240
|
+
_context.t0 = Uint8Array;
|
3241
|
+
_context.next = 3;
|
3242
|
+
return new Response(str).arrayBuffer();
|
3243
|
+
case 3:
|
3244
|
+
_context.t1 = _context.sent;
|
3245
|
+
return _context.abrupt("return", new _context.t0(_context.t1));
|
3246
|
+
case 5:
|
3247
|
+
case "end":
|
3248
|
+
return _context.stop();
|
3249
|
+
}
|
3250
|
+
}, _callee);
|
3251
|
+
}));
|
3252
|
+
return function (_x) {
|
3253
|
+
return _ref.apply(this, arguments);
|
3254
|
+
};
|
3255
|
+
}()));
|
3230
3256
|
var supportsRequestStream = isReadableStreamSupported && function () {
|
3231
3257
|
var duplexAccessed = false;
|
3232
3258
|
var hasContentType = new Request(platform.origin, {
|
@@ -3262,105 +3288,105 @@
|
|
3262
3288
|
});
|
3263
3289
|
}(new Response());
|
3264
3290
|
var getBodyLength = /*#__PURE__*/function () {
|
3265
|
-
var
|
3266
|
-
return _regeneratorRuntime().wrap(function
|
3267
|
-
while (1) switch (
|
3291
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(body) {
|
3292
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
3293
|
+
while (1) switch (_context2.prev = _context2.next) {
|
3268
3294
|
case 0:
|
3269
3295
|
if (!(body == null)) {
|
3270
|
-
|
3296
|
+
_context2.next = 2;
|
3271
3297
|
break;
|
3272
3298
|
}
|
3273
|
-
return
|
3299
|
+
return _context2.abrupt("return", 0);
|
3274
3300
|
case 2:
|
3275
3301
|
if (!utils$1.isBlob(body)) {
|
3276
|
-
|
3302
|
+
_context2.next = 4;
|
3277
3303
|
break;
|
3278
3304
|
}
|
3279
|
-
return
|
3305
|
+
return _context2.abrupt("return", body.size);
|
3280
3306
|
case 4:
|
3281
3307
|
if (!utils$1.isSpecCompliantForm(body)) {
|
3282
|
-
|
3308
|
+
_context2.next = 8;
|
3283
3309
|
break;
|
3284
3310
|
}
|
3285
|
-
|
3311
|
+
_context2.next = 7;
|
3286
3312
|
return new Request(body).arrayBuffer();
|
3287
3313
|
case 7:
|
3288
|
-
return
|
3314
|
+
return _context2.abrupt("return", _context2.sent.byteLength);
|
3289
3315
|
case 8:
|
3290
3316
|
if (!utils$1.isArrayBufferView(body)) {
|
3291
|
-
|
3317
|
+
_context2.next = 10;
|
3292
3318
|
break;
|
3293
3319
|
}
|
3294
|
-
return
|
3320
|
+
return _context2.abrupt("return", body.byteLength);
|
3295
3321
|
case 10:
|
3296
3322
|
if (utils$1.isURLSearchParams(body)) {
|
3297
3323
|
body = body + '';
|
3298
3324
|
}
|
3299
3325
|
if (!utils$1.isString(body)) {
|
3300
|
-
|
3326
|
+
_context2.next = 15;
|
3301
3327
|
break;
|
3302
3328
|
}
|
3303
|
-
|
3304
|
-
return
|
3329
|
+
_context2.next = 14;
|
3330
|
+
return encodeText(body);
|
3305
3331
|
case 14:
|
3306
|
-
return
|
3332
|
+
return _context2.abrupt("return", _context2.sent.byteLength);
|
3307
3333
|
case 15:
|
3308
3334
|
case "end":
|
3309
|
-
return
|
3335
|
+
return _context2.stop();
|
3310
3336
|
}
|
3311
|
-
},
|
3337
|
+
}, _callee2);
|
3312
3338
|
}));
|
3313
|
-
return function getBodyLength(
|
3314
|
-
return
|
3339
|
+
return function getBodyLength(_x2) {
|
3340
|
+
return _ref2.apply(this, arguments);
|
3315
3341
|
};
|
3316
3342
|
}();
|
3317
3343
|
var resolveBodyLength = /*#__PURE__*/function () {
|
3318
|
-
var
|
3344
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(headers, body) {
|
3319
3345
|
var length;
|
3320
|
-
return _regeneratorRuntime().wrap(function
|
3321
|
-
while (1) switch (
|
3346
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
3347
|
+
while (1) switch (_context3.prev = _context3.next) {
|
3322
3348
|
case 0:
|
3323
3349
|
length = utils$1.toFiniteNumber(headers.getContentLength());
|
3324
|
-
return
|
3350
|
+
return _context3.abrupt("return", length == null ? getBodyLength(body) : length);
|
3325
3351
|
case 2:
|
3326
3352
|
case "end":
|
3327
|
-
return
|
3353
|
+
return _context3.stop();
|
3328
3354
|
}
|
3329
|
-
},
|
3355
|
+
}, _callee3);
|
3330
3356
|
}));
|
3331
|
-
return function resolveBodyLength(
|
3332
|
-
return
|
3357
|
+
return function resolveBodyLength(_x3, _x4) {
|
3358
|
+
return _ref3.apply(this, arguments);
|
3333
3359
|
};
|
3334
3360
|
}();
|
3335
3361
|
var fetchAdapter = isFetchSupported && ( /*#__PURE__*/function () {
|
3336
|
-
var
|
3337
|
-
var _resolveConfig, url, method, data, signal, cancelToken, timeout, onDownloadProgress, onUploadProgress, responseType, headers, _resolveConfig$withCr, withCredentials, fetchOptions,
|
3338
|
-
return _regeneratorRuntime().wrap(function
|
3339
|
-
while (1) switch (
|
3362
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(config) {
|
3363
|
+
var _resolveConfig, url, method, data, signal, cancelToken, timeout, onDownloadProgress, onUploadProgress, responseType, headers, _resolveConfig$withCr, withCredentials, fetchOptions, _ref5, _ref6, composedSignal, stopTimeout, finished, request, onFinish, requestContentLength, _request, contentTypeHeader, response, isStreamResponse, options, responseContentLength, responseData;
|
3364
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
3365
|
+
while (1) switch (_context4.prev = _context4.next) {
|
3340
3366
|
case 0:
|
3341
3367
|
_resolveConfig = resolveConfig(config), url = _resolveConfig.url, method = _resolveConfig.method, data = _resolveConfig.data, signal = _resolveConfig.signal, cancelToken = _resolveConfig.cancelToken, timeout = _resolveConfig.timeout, onDownloadProgress = _resolveConfig.onDownloadProgress, onUploadProgress = _resolveConfig.onUploadProgress, responseType = _resolveConfig.responseType, headers = _resolveConfig.headers, _resolveConfig$withCr = _resolveConfig.withCredentials, withCredentials = _resolveConfig$withCr === void 0 ? 'same-origin' : _resolveConfig$withCr, fetchOptions = _resolveConfig.fetchOptions;
|
3342
3368
|
responseType = responseType ? (responseType + '').toLowerCase() : 'text';
|
3343
|
-
|
3369
|
+
_ref5 = signal || cancelToken || timeout ? composeSignals$1([signal, cancelToken], timeout) : [], _ref6 = _slicedToArray(_ref5, 2), composedSignal = _ref6[0], stopTimeout = _ref6[1];
|
3344
3370
|
onFinish = function onFinish() {
|
3345
3371
|
!finished && setTimeout(function () {
|
3346
3372
|
composedSignal && composedSignal.unsubscribe();
|
3347
3373
|
});
|
3348
3374
|
finished = true;
|
3349
3375
|
};
|
3350
|
-
|
3351
|
-
|
3352
|
-
if (!
|
3353
|
-
|
3376
|
+
_context4.prev = 4;
|
3377
|
+
_context4.t0 = onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head';
|
3378
|
+
if (!_context4.t0) {
|
3379
|
+
_context4.next = 11;
|
3354
3380
|
break;
|
3355
3381
|
}
|
3356
|
-
|
3382
|
+
_context4.next = 9;
|
3357
3383
|
return resolveBodyLength(headers, data);
|
3358
3384
|
case 9:
|
3359
|
-
|
3360
|
-
|
3385
|
+
_context4.t1 = requestContentLength = _context4.sent;
|
3386
|
+
_context4.t0 = _context4.t1 !== 0;
|
3361
3387
|
case 11:
|
3362
|
-
if (!
|
3363
|
-
|
3388
|
+
if (!_context4.t0) {
|
3389
|
+
_context4.next = 15;
|
3364
3390
|
break;
|
3365
3391
|
}
|
3366
3392
|
_request = new Request(url, {
|
@@ -3372,7 +3398,7 @@
|
|
3372
3398
|
headers.setContentType(contentTypeHeader);
|
3373
3399
|
}
|
3374
3400
|
if (_request.body) {
|
3375
|
-
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(requestContentLength, progressEventReducer(onUploadProgress)));
|
3401
|
+
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, fetchProgressDecorator(requestContentLength, progressEventReducer(onUploadProgress)), null, encodeText);
|
3376
3402
|
}
|
3377
3403
|
case 15:
|
3378
3404
|
if (!utils$1.isString(withCredentials)) {
|
@@ -3386,10 +3412,10 @@
|
|
3386
3412
|
duplex: "half",
|
3387
3413
|
withCredentials: withCredentials
|
3388
3414
|
}));
|
3389
|
-
|
3415
|
+
_context4.next = 19;
|
3390
3416
|
return fetch(request);
|
3391
3417
|
case 19:
|
3392
|
-
response =
|
3418
|
+
response = _context4.sent;
|
3393
3419
|
isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
|
3394
3420
|
if (supportsResponseStream && (onDownloadProgress || isStreamResponse)) {
|
3395
3421
|
options = {};
|
@@ -3397,16 +3423,16 @@
|
|
3397
3423
|
options[prop] = response[prop];
|
3398
3424
|
});
|
3399
3425
|
responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
|
3400
|
-
response = new Response(trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator(responseContentLength, progressEventReducer(onDownloadProgress, true)), isStreamResponse && onFinish), options);
|
3426
|
+
response = new Response(trackStream(response.body, DEFAULT_CHUNK_SIZE, onDownloadProgress && fetchProgressDecorator(responseContentLength, progressEventReducer(onDownloadProgress, true)), isStreamResponse && onFinish, encodeText), options);
|
3401
3427
|
}
|
3402
3428
|
responseType = responseType || 'text';
|
3403
|
-
|
3429
|
+
_context4.next = 25;
|
3404
3430
|
return resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
|
3405
3431
|
case 25:
|
3406
|
-
responseData =
|
3432
|
+
responseData = _context4.sent;
|
3407
3433
|
!isStreamResponse && onFinish();
|
3408
3434
|
stopTimeout && stopTimeout();
|
3409
|
-
|
3435
|
+
_context4.next = 30;
|
3410
3436
|
return new Promise(function (resolve, reject) {
|
3411
3437
|
settle(resolve, reject, {
|
3412
3438
|
data: responseData,
|
@@ -3418,28 +3444,28 @@
|
|
3418
3444
|
});
|
3419
3445
|
});
|
3420
3446
|
case 30:
|
3421
|
-
return
|
3447
|
+
return _context4.abrupt("return", _context4.sent);
|
3422
3448
|
case 33:
|
3423
|
-
|
3424
|
-
|
3449
|
+
_context4.prev = 33;
|
3450
|
+
_context4.t2 = _context4["catch"](4);
|
3425
3451
|
onFinish();
|
3426
|
-
if (!(
|
3427
|
-
|
3452
|
+
if (!(_context4.t2 && _context4.t2.name === 'TypeError' && /fetch/i.test(_context4.t2.message))) {
|
3453
|
+
_context4.next = 38;
|
3428
3454
|
break;
|
3429
3455
|
}
|
3430
3456
|
throw Object.assign(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request), {
|
3431
|
-
cause:
|
3457
|
+
cause: _context4.t2.cause || _context4.t2
|
3432
3458
|
});
|
3433
3459
|
case 38:
|
3434
|
-
throw AxiosError.from(
|
3460
|
+
throw AxiosError.from(_context4.t2, _context4.t2 && _context4.t2.code, config, request);
|
3435
3461
|
case 39:
|
3436
3462
|
case "end":
|
3437
|
-
return
|
3463
|
+
return _context4.stop();
|
3438
3464
|
}
|
3439
|
-
},
|
3465
|
+
}, _callee4, null, [[4, 33]]);
|
3440
3466
|
}));
|
3441
|
-
return function (
|
3442
|
-
return
|
3467
|
+
return function (_x5) {
|
3468
|
+
return _ref4.apply(this, arguments);
|
3443
3469
|
};
|
3444
3470
|
}());
|
3445
3471
|
|
@@ -3560,7 +3586,7 @@
|
|
3560
3586
|
});
|
3561
3587
|
}
|
3562
3588
|
|
3563
|
-
var VERSION = "1.7.
|
3589
|
+
var VERSION = "1.7.1";
|
3564
3590
|
|
3565
3591
|
var validators$1 = {};
|
3566
3592
|
|