axios 0.27.1 → 0.28.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.
- package/CHANGELOG.md +127 -57
- package/README.md +271 -80
- package/SECURITY.md +3 -3
- package/UPGRADE_GUIDE.md +16 -15
- package/bin/check-build-version.js +19 -0
- package/bin/ssl_hotfix.js +22 -0
- package/dist/axios.js +1961 -4280
- package/dist/axios.js.map +1 -0
- package/dist/axios.min.js +2 -12
- package/dist/axios.min.js.map +1 -0
- package/dist/esm/axios.js +2354 -0
- package/dist/esm/axios.js.map +1 -0
- package/dist/esm/axios.min.js +2 -0
- package/dist/esm/axios.min.js.map +1 -0
- package/index.d.ts +104 -19
- package/lib/adapters/http.js +153 -114
- package/lib/adapters/xhr.js +20 -12
- package/lib/axios.js +5 -1
- package/lib/cancel/CancelToken.js +4 -5
- package/lib/cancel/CanceledError.js +4 -2
- package/lib/core/Axios.js +6 -1
- package/lib/core/AxiosError.js +12 -1
- package/lib/core/InterceptorManager.js +9 -0
- package/lib/core/dispatchRequest.js +7 -0
- package/lib/core/mergeConfig.js +3 -0
- package/lib/core/transformData.js +3 -2
- package/lib/defaults/index.js +42 -13
- package/lib/env/data.js +1 -1
- package/lib/helpers/AxiosURLSearchParams.js +42 -0
- package/lib/helpers/bind.js +1 -5
- package/lib/helpers/buildURL.js +14 -37
- package/lib/helpers/formDataToJSON.js +71 -0
- package/lib/helpers/fromDataURI.js +51 -0
- package/lib/helpers/isURLSameOrigin.js +12 -12
- package/lib/helpers/parseHeaders.js +2 -2
- package/lib/helpers/parseProtocol.js +6 -0
- package/lib/helpers/toFormData.js +141 -34
- package/lib/helpers/toURLEncodedForm.js +18 -0
- package/lib/platform/browser/classes/FormData.js +3 -0
- package/lib/platform/browser/classes/URLSearchParams.js +5 -0
- package/lib/platform/browser/index.js +11 -0
- package/lib/platform/index.js +3 -0
- package/lib/platform/node/classes/FormData.js +3 -0
- package/lib/platform/node/classes/URLSearchParams.js +5 -0
- package/lib/platform/node/index.js +11 -0
- package/lib/utils.js +68 -16
- package/package.json +18 -8
- package/rollup.config.js +60 -0
- package/dist/axios.map +0 -1
- package/dist/axios.min.map +0 -1
- /package/lib/{defaults/env → env/classes}/FormData.js +0 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
module.exports = {
|
4
|
+
isNode: true,
|
5
|
+
classes: {
|
6
|
+
URLSearchParams: require('./classes/URLSearchParams'),
|
7
|
+
FormData: require('./classes/FormData'),
|
8
|
+
Blob: typeof Blob !== 'undefined' && Blob || null
|
9
|
+
},
|
10
|
+
protocols: [ 'http', 'https', 'file', 'data' ]
|
11
|
+
};
|
package/lib/utils.js
CHANGED
@@ -124,6 +124,16 @@ function isPlainObject(val) {
|
|
124
124
|
return prototype === null || prototype === Object.prototype;
|
125
125
|
}
|
126
126
|
|
127
|
+
/**
|
128
|
+
* Determine if a value is a empty Object
|
129
|
+
*
|
130
|
+
* @param {Object} val The value to test
|
131
|
+
* @return {boolean} True if value is a empty Object, otherwise false
|
132
|
+
*/
|
133
|
+
function isEmptyObject(val) {
|
134
|
+
return val && Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
135
|
+
}
|
136
|
+
|
127
137
|
/**
|
128
138
|
* Determine if a value is a Date
|
129
139
|
*
|
@@ -210,7 +220,7 @@ var isURLSearchParams = kindOfTest('URLSearchParams');
|
|
210
220
|
* @returns {String} The String freed of excess whitespace
|
211
221
|
*/
|
212
222
|
function trim(str) {
|
213
|
-
return str.trim ? str.trim() : str.replace(
|
223
|
+
return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
214
224
|
}
|
215
225
|
|
216
226
|
/**
|
@@ -229,15 +239,16 @@ function trim(str) {
|
|
229
239
|
* navigator.product -> 'NativeScript' or 'NS'
|
230
240
|
*/
|
231
241
|
function isStandardBrowserEnv() {
|
232
|
-
|
233
|
-
|
234
|
-
|
242
|
+
var product;
|
243
|
+
if (typeof navigator !== 'undefined' && (
|
244
|
+
(product = navigator.product) === 'ReactNative' ||
|
245
|
+
product === 'NativeScript' ||
|
246
|
+
product === 'NS')
|
247
|
+
) {
|
235
248
|
return false;
|
236
249
|
}
|
237
|
-
|
238
|
-
|
239
|
-
typeof document !== 'undefined'
|
240
|
-
);
|
250
|
+
|
251
|
+
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
241
252
|
}
|
242
253
|
|
243
254
|
/**
|
@@ -366,29 +377,32 @@ function inherits(constructor, superConstructor, props, descriptors) {
|
|
366
377
|
* Resolve object with deep prototype chain to a flat object
|
367
378
|
* @param {Object} sourceObj source object
|
368
379
|
* @param {Object} [destObj]
|
369
|
-
* @param {Function} [filter]
|
380
|
+
* @param {Function|Boolean} [filter]
|
381
|
+
* @param {Function} [propFilter]
|
370
382
|
* @returns {Object}
|
371
383
|
*/
|
372
384
|
|
373
|
-
function toFlatObject(sourceObj, destObj, filter) {
|
385
|
+
function toFlatObject(sourceObj, destObj, filter, propFilter) {
|
374
386
|
var props;
|
375
387
|
var i;
|
376
388
|
var prop;
|
377
389
|
var merged = {};
|
378
390
|
|
379
391
|
destObj = destObj || {};
|
392
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
393
|
+
if (sourceObj == null) return destObj;
|
380
394
|
|
381
395
|
do {
|
382
396
|
props = Object.getOwnPropertyNames(sourceObj);
|
383
397
|
i = props.length;
|
384
398
|
while (i-- > 0) {
|
385
399
|
prop = props[i];
|
386
|
-
if (!merged[prop]) {
|
400
|
+
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
|
387
401
|
destObj[prop] = sourceObj[prop];
|
388
402
|
merged[prop] = true;
|
389
403
|
}
|
390
404
|
}
|
391
|
-
sourceObj = Object.getPrototypeOf(sourceObj);
|
405
|
+
sourceObj = filter !== false && Object.getPrototypeOf(sourceObj);
|
392
406
|
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
393
407
|
|
394
408
|
return destObj;
|
@@ -413,14 +427,15 @@ function endsWith(str, searchString, position) {
|
|
413
427
|
|
414
428
|
|
415
429
|
/**
|
416
|
-
* Returns new array from array like object
|
430
|
+
* Returns new array from array like object or null if failed
|
417
431
|
* @param {*} [thing]
|
418
|
-
* @returns {Array}
|
432
|
+
* @returns {?Array}
|
419
433
|
*/
|
420
434
|
function toArray(thing) {
|
421
435
|
if (!thing) return null;
|
436
|
+
if (isArray(thing)) return thing;
|
422
437
|
var i = thing.length;
|
423
|
-
if (
|
438
|
+
if (!isNumber(i)) return null;
|
424
439
|
var arr = new Array(i);
|
425
440
|
while (i-- > 0) {
|
426
441
|
arr[i] = thing[i];
|
@@ -436,6 +451,38 @@ var isTypedArray = (function(TypedArray) {
|
|
436
451
|
};
|
437
452
|
})(typeof Uint8Array !== 'undefined' && Object.getPrototypeOf(Uint8Array));
|
438
453
|
|
454
|
+
function forEachEntry(obj, fn) {
|
455
|
+
var generator = obj && obj[Symbol.iterator];
|
456
|
+
|
457
|
+
var iterator = generator.call(obj);
|
458
|
+
|
459
|
+
var result;
|
460
|
+
|
461
|
+
while ((result = iterator.next()) && !result.done) {
|
462
|
+
var pair = result.value;
|
463
|
+
fn.call(obj, pair[0], pair[1]);
|
464
|
+
}
|
465
|
+
}
|
466
|
+
|
467
|
+
function matchAll(regExp, str) {
|
468
|
+
var matches;
|
469
|
+
var arr = [];
|
470
|
+
|
471
|
+
while ((matches = regExp.exec(str)) !== null) {
|
472
|
+
arr.push(matches);
|
473
|
+
}
|
474
|
+
|
475
|
+
return arr;
|
476
|
+
}
|
477
|
+
|
478
|
+
var isHTMLForm = kindOfTest('HTMLFormElement');
|
479
|
+
|
480
|
+
var hasOwnProperty = (function resolver(_hasOwnProperty) {
|
481
|
+
return function(obj, prop) {
|
482
|
+
return _hasOwnProperty.call(obj, prop);
|
483
|
+
};
|
484
|
+
})(Object.prototype.hasOwnProperty);
|
485
|
+
|
439
486
|
module.exports = {
|
440
487
|
isArray: isArray,
|
441
488
|
isArrayBuffer: isArrayBuffer,
|
@@ -446,6 +493,7 @@ module.exports = {
|
|
446
493
|
isNumber: isNumber,
|
447
494
|
isObject: isObject,
|
448
495
|
isPlainObject: isPlainObject,
|
496
|
+
isEmptyObject: isEmptyObject,
|
449
497
|
isUndefined: isUndefined,
|
450
498
|
isDate: isDate,
|
451
499
|
isFile: isFile,
|
@@ -466,5 +514,9 @@ module.exports = {
|
|
466
514
|
endsWith: endsWith,
|
467
515
|
toArray: toArray,
|
468
516
|
isTypedArray: isTypedArray,
|
469
|
-
isFileList: isFileList
|
517
|
+
isFileList: isFileList,
|
518
|
+
forEachEntry: forEachEntry,
|
519
|
+
matchAll: matchAll,
|
520
|
+
isHTMLForm: isHTMLForm,
|
521
|
+
hasOwnProperty: hasOwnProperty
|
470
522
|
};
|
package/package.json
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "axios",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.28.0",
|
4
4
|
"description": "Promise based HTTP client for the browser and node.js",
|
5
5
|
"main": "index.js",
|
6
6
|
"types": "index.d.ts",
|
7
7
|
"scripts": {
|
8
|
-
"test": "grunt test && dtslint",
|
8
|
+
"test": "node bin/ssl_hotfix.js grunt test && node bin/ssl_hotfix.js dtslint --localTs node_modules/typescript/lib",
|
9
9
|
"start": "node ./sandbox/server.js",
|
10
|
-
"build": "cross-env NODE_ENV=production grunt build",
|
11
10
|
"preversion": "grunt version && npm test",
|
12
|
-
"
|
13
|
-
"postversion": "git push && git push --tags",
|
11
|
+
"build": "cross-env NODE_ENV=production grunt build",
|
14
12
|
"examples": "node ./examples/server.js",
|
15
13
|
"coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
|
16
14
|
"fix": "eslint --fix lib/**/*.js"
|
@@ -33,11 +31,18 @@
|
|
33
31
|
},
|
34
32
|
"homepage": "https://axios-http.com",
|
35
33
|
"devDependencies": {
|
34
|
+
"@rollup/plugin-babel": "^5.3.0",
|
35
|
+
"@rollup/plugin-commonjs": "^15.1.0",
|
36
|
+
"@rollup/plugin-json": "^4.1.0",
|
37
|
+
"@rollup/plugin-multi-entry": "^4.0.0",
|
38
|
+
"@rollup/plugin-node-resolve": "^9.0.0",
|
36
39
|
"abortcontroller-polyfill": "^1.7.3",
|
40
|
+
"body-parser": "^1.20.0",
|
37
41
|
"coveralls": "^3.1.1",
|
38
42
|
"cross-env": "^7.0.3",
|
39
43
|
"dtslint": "^4.2.1",
|
40
44
|
"es6-promise": "^4.2.8",
|
45
|
+
"express": "^4.18.1",
|
41
46
|
"formidable": "^2.0.1",
|
42
47
|
"grunt": "^1.4.1",
|
43
48
|
"grunt-banner": "^0.6.0",
|
@@ -47,6 +52,7 @@
|
|
47
52
|
"grunt-eslint": "^24.0.0",
|
48
53
|
"grunt-karma": "^4.0.2",
|
49
54
|
"grunt-mocha-test": "^0.13.3",
|
55
|
+
"grunt-shell": "^3.0.1",
|
50
56
|
"grunt-webpack": "^5.0.0",
|
51
57
|
"istanbul-instrumenter-loader": "^3.0.1",
|
52
58
|
"jasmine-core": "^2.4.1",
|
@@ -63,6 +69,9 @@
|
|
63
69
|
"load-grunt-tasks": "^5.1.0",
|
64
70
|
"minimist": "^1.2.6",
|
65
71
|
"mocha": "^8.2.1",
|
72
|
+
"multer": "^1.4.4",
|
73
|
+
"rollup": "^2.67.0",
|
74
|
+
"rollup-plugin-terser": "^7.0.2",
|
66
75
|
"sinon": "^4.5.0",
|
67
76
|
"terser-webpack-plugin": "^4.2.3",
|
68
77
|
"typescript": "^4.6.3",
|
@@ -72,14 +81,15 @@
|
|
72
81
|
},
|
73
82
|
"browser": {
|
74
83
|
"./lib/adapters/http.js": "./lib/adapters/xhr.js",
|
75
|
-
"./lib/
|
84
|
+
"./lib/platform/node/index.js": "./lib/platform/browser/index.js"
|
76
85
|
},
|
77
86
|
"jsdelivr": "dist/axios.min.js",
|
78
87
|
"unpkg": "dist/axios.min.js",
|
79
88
|
"typings": "./index.d.ts",
|
80
89
|
"dependencies": {
|
81
|
-
"follow-redirects": "^1.
|
82
|
-
"form-data": "^4.0.0"
|
90
|
+
"follow-redirects": "^1.15.0",
|
91
|
+
"form-data": "^4.0.0",
|
92
|
+
"proxy-from-env": "^1.1.0"
|
83
93
|
},
|
84
94
|
"bundlesize": [
|
85
95
|
{
|
package/rollup.config.js
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
import resolve from '@rollup/plugin-node-resolve';
|
2
|
+
import commonjs from '@rollup/plugin-commonjs';
|
3
|
+
import {terser} from "rollup-plugin-terser";
|
4
|
+
import json from '@rollup/plugin-json';
|
5
|
+
|
6
|
+
const lib = require("./package.json");
|
7
|
+
const outputFileName = 'axios';
|
8
|
+
const name = "axios";
|
9
|
+
const input = './lib/axios.js';
|
10
|
+
|
11
|
+
const buildConfig = (config) => {
|
12
|
+
|
13
|
+
const build = ({minified}) => ({
|
14
|
+
input,
|
15
|
+
...config,
|
16
|
+
output: {
|
17
|
+
...config.output,
|
18
|
+
file: `${config.output.file}.${minified ? "min.js" : "js"}`
|
19
|
+
},
|
20
|
+
plugins: [
|
21
|
+
json(),
|
22
|
+
resolve({browser: true}),
|
23
|
+
commonjs(),
|
24
|
+
minified && terser(),
|
25
|
+
...(config.plugins || []),
|
26
|
+
]
|
27
|
+
});
|
28
|
+
|
29
|
+
return [
|
30
|
+
build({minified: false}),
|
31
|
+
build({minified: true}),
|
32
|
+
];
|
33
|
+
};
|
34
|
+
|
35
|
+
export default async () => {
|
36
|
+
const year = new Date().getFullYear();
|
37
|
+
const banner = `// ${lib.name} v${lib.version} Copyright (c) ${year} ${lib.author}`;
|
38
|
+
|
39
|
+
return [
|
40
|
+
...buildConfig({
|
41
|
+
output: {
|
42
|
+
file: `dist/${outputFileName}`,
|
43
|
+
name,
|
44
|
+
format: "umd",
|
45
|
+
exports: "default",
|
46
|
+
banner
|
47
|
+
}
|
48
|
+
}),
|
49
|
+
|
50
|
+
...buildConfig({
|
51
|
+
output: {
|
52
|
+
file: `dist/esm/${outputFileName}`,
|
53
|
+
format: "esm",
|
54
|
+
preferConst: true,
|
55
|
+
exports: "named",
|
56
|
+
banner
|
57
|
+
}
|
58
|
+
})
|
59
|
+
]
|
60
|
+
};
|