axios 0.27.0 → 1.0.0-alpha.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 +124 -927
- package/LICENSE +4 -16
- package/README.md +257 -69
- package/SECURITY.md +3 -3
- package/UPGRADE_GUIDE.md +1 -166
- package/bin/ssl_hotfix.js +22 -0
- package/dist/axios.js +1956 -3592
- package/dist/axios.js.map +1 -0
- package/dist/axios.min.js +2 -4
- package/dist/axios.min.js.map +1 -0
- package/dist/esm/axios.js +2336 -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 +96 -18
- package/lib/adapters/http.js +154 -113
- package/lib/adapters/xhr.js +12 -11
- 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 +2 -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/transformData.js +3 -2
- package/lib/defaults/index.js +45 -13
- package/lib/{defaults/env → env/classes}/FormData.js +0 -0
- 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 +57 -34
- package/package.json +18 -8
- package/rollup.config.js +60 -0
- package/dist/axios.map +0 -1
- package/dist/axios.min.map +0 -1
@@ -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
@@ -22,22 +22,6 @@ function kindOfTest(type) {
|
|
22
22
|
};
|
23
23
|
}
|
24
24
|
|
25
|
-
/**
|
26
|
-
* Array with axios supported protocols.
|
27
|
-
*/
|
28
|
-
var supportedProtocols = [ 'http:', 'https:', 'file:' ];
|
29
|
-
|
30
|
-
/**
|
31
|
-
* Returns URL protocol passed as param if is not undefined or null,
|
32
|
-
* otherwise just returns 'http:'
|
33
|
-
*
|
34
|
-
* @param {String} protocol The String value of URL protocol
|
35
|
-
* @returns {String} Protocol if the value is not undefined or null
|
36
|
-
*/
|
37
|
-
function getProtocol(protocol) {
|
38
|
-
return protocol || 'http:';
|
39
|
-
}
|
40
|
-
|
41
25
|
/**
|
42
26
|
* Determine if a value is an Array
|
43
27
|
*
|
@@ -226,7 +210,7 @@ var isURLSearchParams = kindOfTest('URLSearchParams');
|
|
226
210
|
* @returns {String} The String freed of excess whitespace
|
227
211
|
*/
|
228
212
|
function trim(str) {
|
229
|
-
return str.trim ? str.trim() : str.replace(
|
213
|
+
return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
|
230
214
|
}
|
231
215
|
|
232
216
|
/**
|
@@ -245,15 +229,16 @@ function trim(str) {
|
|
245
229
|
* navigator.product -> 'NativeScript' or 'NS'
|
246
230
|
*/
|
247
231
|
function isStandardBrowserEnv() {
|
248
|
-
|
249
|
-
|
250
|
-
|
232
|
+
var product;
|
233
|
+
if (typeof navigator !== 'undefined' && (
|
234
|
+
(product = navigator.product) === 'ReactNative' ||
|
235
|
+
product === 'NativeScript' ||
|
236
|
+
product === 'NS')
|
237
|
+
) {
|
251
238
|
return false;
|
252
239
|
}
|
253
|
-
|
254
|
-
|
255
|
-
typeof document !== 'undefined'
|
256
|
-
);
|
240
|
+
|
241
|
+
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
257
242
|
}
|
258
243
|
|
259
244
|
/**
|
@@ -382,29 +367,32 @@ function inherits(constructor, superConstructor, props, descriptors) {
|
|
382
367
|
* Resolve object with deep prototype chain to a flat object
|
383
368
|
* @param {Object} sourceObj source object
|
384
369
|
* @param {Object} [destObj]
|
385
|
-
* @param {Function} [filter]
|
370
|
+
* @param {Function|Boolean} [filter]
|
371
|
+
* @param {Function} [propFilter]
|
386
372
|
* @returns {Object}
|
387
373
|
*/
|
388
374
|
|
389
|
-
function toFlatObject(sourceObj, destObj, filter) {
|
375
|
+
function toFlatObject(sourceObj, destObj, filter, propFilter) {
|
390
376
|
var props;
|
391
377
|
var i;
|
392
378
|
var prop;
|
393
379
|
var merged = {};
|
394
380
|
|
395
381
|
destObj = destObj || {};
|
382
|
+
// eslint-disable-next-line no-eq-null,eqeqeq
|
383
|
+
if (sourceObj == null) return destObj;
|
396
384
|
|
397
385
|
do {
|
398
386
|
props = Object.getOwnPropertyNames(sourceObj);
|
399
387
|
i = props.length;
|
400
388
|
while (i-- > 0) {
|
401
389
|
prop = props[i];
|
402
|
-
if (!merged[prop]) {
|
390
|
+
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
|
403
391
|
destObj[prop] = sourceObj[prop];
|
404
392
|
merged[prop] = true;
|
405
393
|
}
|
406
394
|
}
|
407
|
-
sourceObj = Object.getPrototypeOf(sourceObj);
|
395
|
+
sourceObj = filter !== false && Object.getPrototypeOf(sourceObj);
|
408
396
|
} while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
409
397
|
|
410
398
|
return destObj;
|
@@ -429,14 +417,15 @@ function endsWith(str, searchString, position) {
|
|
429
417
|
|
430
418
|
|
431
419
|
/**
|
432
|
-
* Returns new array from array like object
|
420
|
+
* Returns new array from array like object or null if failed
|
433
421
|
* @param {*} [thing]
|
434
|
-
* @returns {Array}
|
422
|
+
* @returns {?Array}
|
435
423
|
*/
|
436
424
|
function toArray(thing) {
|
437
425
|
if (!thing) return null;
|
426
|
+
if (isArray(thing)) return thing;
|
438
427
|
var i = thing.length;
|
439
|
-
if (
|
428
|
+
if (!isNumber(i)) return null;
|
440
429
|
var arr = new Array(i);
|
441
430
|
while (i-- > 0) {
|
442
431
|
arr[i] = thing[i];
|
@@ -452,9 +441,39 @@ var isTypedArray = (function(TypedArray) {
|
|
452
441
|
};
|
453
442
|
})(typeof Uint8Array !== 'undefined' && Object.getPrototypeOf(Uint8Array));
|
454
443
|
|
444
|
+
function forEachEntry(obj, fn) {
|
445
|
+
var generator = obj && obj[Symbol.iterator];
|
446
|
+
|
447
|
+
var iterator = generator.call(obj);
|
448
|
+
|
449
|
+
var result;
|
450
|
+
|
451
|
+
while ((result = iterator.next()) && !result.done) {
|
452
|
+
var pair = result.value;
|
453
|
+
fn.call(obj, pair[0], pair[1]);
|
454
|
+
}
|
455
|
+
}
|
456
|
+
|
457
|
+
function matchAll(regExp, str) {
|
458
|
+
var matches;
|
459
|
+
var arr = [];
|
460
|
+
|
461
|
+
while ((matches = regExp.exec(str)) !== null) {
|
462
|
+
arr.push(matches);
|
463
|
+
}
|
464
|
+
|
465
|
+
return arr;
|
466
|
+
}
|
467
|
+
|
468
|
+
var isHTMLForm = kindOfTest('HTMLFormElement');
|
469
|
+
|
470
|
+
var hasOwnProperty = (function resolver(_hasOwnProperty) {
|
471
|
+
return function(obj, prop) {
|
472
|
+
return _hasOwnProperty.call(obj, prop);
|
473
|
+
};
|
474
|
+
})(Object.prototype.hasOwnProperty);
|
475
|
+
|
455
476
|
module.exports = {
|
456
|
-
supportedProtocols: supportedProtocols,
|
457
|
-
getProtocol: getProtocol,
|
458
477
|
isArray: isArray,
|
459
478
|
isArrayBuffer: isArrayBuffer,
|
460
479
|
isBuffer: isBuffer,
|
@@ -484,5 +503,9 @@ module.exports = {
|
|
484
503
|
endsWith: endsWith,
|
485
504
|
toArray: toArray,
|
486
505
|
isTypedArray: isTypedArray,
|
487
|
-
isFileList: isFileList
|
506
|
+
isFileList: isFileList,
|
507
|
+
forEachEntry: forEachEntry,
|
508
|
+
matchAll: matchAll,
|
509
|
+
isHTMLForm: isHTMLForm,
|
510
|
+
hasOwnProperty: hasOwnProperty
|
488
511
|
};
|
package/package.json
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "axios",
|
3
|
-
"version": "0.
|
3
|
+
"version": "1.0.0-alpha.1",
|
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",
|
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
|
+
};
|