@wopee-io/wopee.wdio 4.7.0 → 5.0.2
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/build/adapter/fullPageScreenshotAdapter/fullPageScreenshotAdapter.d.ts +2 -2
- package/build/adapter/fullPageScreenshotAdapter/fullPageScreenshotAdapter.d.ts.map +1 -1
- package/build/adapter/fullPageScreenshotAdapter/fullPageScreenshotAdapter.js +18 -20
- package/build/adapter/fullPageScreenshotAdapter/fullPageScreenshotAdapter.js.map +1 -1
- package/build/desktopBrowser/commands/trackElement.js +2 -2
- package/build/desktopBrowser/commands/trackElement.js.map +1 -1
- package/build/desktopBrowser/commands/trackScreen.js +2 -2
- package/build/desktopBrowser/commands/trackScreen.js.map +1 -1
- package/build/desktopBrowser/methods/images.d.ts +1 -1
- package/build/desktopBrowser/methods/images.d.ts.map +1 -1
- package/build/desktopBrowser/methods/images.interfaces.d.ts +2 -2
- package/build/desktopBrowser/methods/images.interfaces.d.ts.map +1 -1
- package/build/desktopBrowser/methods/images.interfaces.js.map +1 -1
- package/build/desktopBrowser/methods/images.js +5 -5
- package/build/desktopBrowser/methods/images.js.map +1 -1
- package/build/domain/model/config.interface.d.ts +82 -13
- package/build/domain/model/config.interface.d.ts.map +1 -1
- package/build/domain/model/config.interface.js +16 -1
- package/build/domain/model/config.interface.js.map +1 -1
- package/build/domain/model/service.interface.d.ts +3 -3
- package/build/domain/model/service.interface.d.ts.map +1 -1
- package/build/domain/model/service.interface.js.map +1 -1
- package/build/domain/service/configurationService.d.ts +5 -0
- package/build/domain/service/configurationService.d.ts.map +1 -0
- package/build/domain/service/configurationService.js +65 -0
- package/build/domain/service/configurationService.js.map +1 -0
- package/build/domain/service/wopeeService.d.ts.map +1 -1
- package/build/domain/service/wopeeService.js +2 -2
- package/build/domain/service/wopeeService.js.map +1 -1
- package/build/utils/versionMetadata.js +2 -2
- package/docs/configuration.md +9 -18
- package/node_modules/@autonomous-testing/sdk/.github/workflows/ci_cd.yaml +3 -1
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/createIntegrationStepPayload.interface.d.ts +6 -0
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/createIntegrationStepPayload.interface.js +2 -0
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/index.d.ts +9 -13
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/index.js +5 -1
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/visualAssert.interface.d.ts +22 -0
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/visualAssert.interface.js +18 -0
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/visualAssertPayload.interface.d.ts +17 -0
- package/node_modules/@autonomous-testing/sdk/build/core/domain/entities/visualAssertPayload.interface.js +11 -0
- package/node_modules/@autonomous-testing/sdk/build/core/ports/api.d.ts +2 -1
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/adapter.d.ts +2 -1
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/adapter.js +10 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/factories.d.ts +5 -3
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/factories.js +23 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/interface.d.ts +63 -4
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/interface.js +21 -2
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/mutations.d.ts +1 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/mutations.js +8 -1
- package/node_modules/@autonomous-testing/sdk/build/shared/metadata/versionMetadata.js +2 -2
- package/node_modules/@autonomous-testing/sdk/package.json +7 -5
- package/node_modules/axios/CHANGELOG.md +157 -61
- package/node_modules/axios/README.md +271 -80
- package/node_modules/axios/SECURITY.md +3 -3
- package/node_modules/axios/UPGRADE_GUIDE.md +37 -15
- package/node_modules/axios/bin/check-build-version.js +19 -0
- package/node_modules/axios/bin/ssl_hotfix.js +22 -0
- package/node_modules/axios/dist/axios.js +2014 -2222
- package/node_modules/axios/dist/axios.js.map +1 -0
- package/node_modules/axios/dist/axios.min.js +2 -3
- package/node_modules/axios/dist/axios.min.js.map +1 -0
- package/node_modules/axios/dist/esm/axios.js +2379 -0
- package/node_modules/axios/dist/esm/axios.js.map +1 -0
- package/node_modules/axios/dist/esm/axios.min.js +2 -0
- package/node_modules/axios/dist/esm/axios.min.js.map +1 -0
- package/node_modules/axios/index.d.ts +106 -19
- package/node_modules/axios/lib/adapters/http.js +155 -116
- package/node_modules/axios/lib/adapters/xhr.js +15 -11
- package/node_modules/axios/lib/axios.js +5 -1
- package/node_modules/axios/lib/cancel/CancelToken.js +4 -5
- package/node_modules/axios/lib/cancel/CanceledError.js +4 -2
- package/node_modules/axios/lib/core/Axios.js +18 -2
- package/node_modules/axios/lib/core/AxiosError.js +12 -1
- package/node_modules/axios/lib/core/InterceptorManager.js +9 -0
- package/node_modules/axios/lib/core/buildFullPath.js +5 -2
- package/node_modules/axios/lib/core/dispatchRequest.js +7 -0
- package/node_modules/axios/lib/core/mergeConfig.js +3 -0
- package/node_modules/axios/lib/core/transformData.js +3 -2
- package/node_modules/axios/lib/defaults/index.js +42 -13
- package/node_modules/axios/lib/env/data.js +1 -1
- package/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +42 -0
- package/node_modules/axios/lib/helpers/bind.js +1 -5
- package/node_modules/axios/lib/helpers/buildURL.js +18 -33
- package/node_modules/axios/lib/helpers/combineURLs.js +1 -1
- package/node_modules/axios/lib/helpers/formDataToJSON.js +74 -0
- package/node_modules/axios/lib/helpers/fromDataURI.js +51 -0
- package/node_modules/axios/lib/helpers/isURLSameOrigin.js +12 -12
- package/node_modules/axios/lib/helpers/parseHeaders.js +2 -2
- package/node_modules/axios/lib/helpers/toFormData.js +141 -34
- package/node_modules/axios/lib/helpers/toURLEncodedForm.js +18 -0
- package/node_modules/axios/lib/platform/browser/classes/FormData.js +3 -0
- package/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +5 -0
- package/node_modules/axios/lib/platform/browser/index.js +11 -0
- package/node_modules/axios/lib/platform/index.js +3 -0
- package/node_modules/axios/lib/platform/node/classes/FormData.js +3 -0
- package/node_modules/axios/lib/platform/node/classes/URLSearchParams.js +5 -0
- package/node_modules/axios/lib/platform/node/index.js +11 -0
- package/node_modules/axios/lib/utils.js +68 -16
- package/node_modules/axios/package.json +20 -7
- package/node_modules/axios/rollup.config.js +60 -0
- package/node_modules/proxy-from-env/.eslintrc +29 -0
- package/node_modules/proxy-from-env/.travis.yml +10 -0
- package/node_modules/proxy-from-env/LICENSE +20 -0
- package/node_modules/proxy-from-env/README.md +131 -0
- package/node_modules/proxy-from-env/index.js +108 -0
- package/node_modules/proxy-from-env/package.json +34 -0
- package/node_modules/proxy-from-env/test.js +483 -0
- package/package.json +4 -4
- package/build/adapter/wdioConfigAdapter/wdioConfigAdapter.d.ts +0 -10
- package/build/adapter/wdioConfigAdapter/wdioConfigAdapter.d.ts.map +0 -1
- package/build/adapter/wdioConfigAdapter/wdioConfigAdapter.interface.d.ts +0 -28
- package/build/adapter/wdioConfigAdapter/wdioConfigAdapter.interface.d.ts.map +0 -1
- package/build/adapter/wdioConfigAdapter/wdioConfigAdapter.interface.js +0 -12
- package/build/adapter/wdioConfigAdapter/wdioConfigAdapter.interface.js.map +0 -1
- package/build/adapter/wdioConfigAdapter/wdioConfigAdapter.js +0 -57
- package/build/adapter/wdioConfigAdapter/wdioConfigAdapter.js.map +0 -1
- package/build/domain/model/croppingOptions.interface.d.ts +0 -8
- package/build/domain/model/croppingOptions.interface.d.ts.map +0 -1
- package/build/domain/model/croppingOptions.interface.js +0 -12
- package/build/domain/model/croppingOptions.interface.js.map +0 -1
- package/build/port/driven/configDrivingPort/configDrivingPort.d.ts +0 -9
- package/build/port/driven/configDrivingPort/configDrivingPort.d.ts.map +0 -1
- package/build/port/driven/configDrivingPort/configDrivingPort.js +0 -15
- package/build/port/driven/configDrivingPort/configDrivingPort.js.map +0 -1
- package/build/port/driven/configDrivingPort/configDrivingPortDefaults.d.ts +0 -6
- package/build/port/driven/configDrivingPort/configDrivingPortDefaults.d.ts.map +0 -1
- package/build/port/driven/configDrivingPort/configDrivingPortDefaults.js +0 -36
- package/build/port/driven/configDrivingPort/configDrivingPortDefaults.js.map +0 -1
- package/node_modules/axios/dist/axios.map +0 -1
- package/node_modules/axios/dist/axios.min.map +0 -1
- /package/node_modules/axios/lib/{defaults/env → env/classes}/FormData.js +0 -0
|
@@ -5,6 +5,7 @@ var transformData = require('./transformData');
|
|
|
5
5
|
var isCancel = require('../cancel/isCancel');
|
|
6
6
|
var defaults = require('../defaults');
|
|
7
7
|
var CanceledError = require('../cancel/CanceledError');
|
|
8
|
+
var normalizeHeaderName = require('../helpers/normalizeHeaderName');
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Throws a `CanceledError` if cancellation has been requested.
|
|
@@ -36,9 +37,13 @@ module.exports = function dispatchRequest(config) {
|
|
|
36
37
|
config,
|
|
37
38
|
config.data,
|
|
38
39
|
config.headers,
|
|
40
|
+
null,
|
|
39
41
|
config.transformRequest
|
|
40
42
|
);
|
|
41
43
|
|
|
44
|
+
normalizeHeaderName(config.headers, 'Accept');
|
|
45
|
+
normalizeHeaderName(config.headers, 'Content-Type');
|
|
46
|
+
|
|
42
47
|
// Flatten headers
|
|
43
48
|
config.headers = utils.merge(
|
|
44
49
|
config.headers.common || {},
|
|
@@ -63,6 +68,7 @@ module.exports = function dispatchRequest(config) {
|
|
|
63
68
|
config,
|
|
64
69
|
response.data,
|
|
65
70
|
response.headers,
|
|
71
|
+
response.status,
|
|
66
72
|
config.transformResponse
|
|
67
73
|
);
|
|
68
74
|
|
|
@@ -77,6 +83,7 @@ module.exports = function dispatchRequest(config) {
|
|
|
77
83
|
config,
|
|
78
84
|
reason.response.data,
|
|
79
85
|
reason.response.headers,
|
|
86
|
+
reason.response.status,
|
|
80
87
|
config.transformResponse
|
|
81
88
|
);
|
|
82
89
|
}
|
|
@@ -18,6 +18,8 @@ module.exports = function mergeConfig(config1, config2) {
|
|
|
18
18
|
function getMergedValue(target, source) {
|
|
19
19
|
if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
|
|
20
20
|
return utils.merge(target, source);
|
|
21
|
+
} else if (utils.isEmptyObject(source)) {
|
|
22
|
+
return utils.merge({}, target);
|
|
21
23
|
} else if (utils.isPlainObject(source)) {
|
|
22
24
|
return utils.merge({}, source);
|
|
23
25
|
} else if (utils.isArray(source)) {
|
|
@@ -71,6 +73,7 @@ module.exports = function mergeConfig(config1, config2) {
|
|
|
71
73
|
'timeout': defaultToConfig2,
|
|
72
74
|
'timeoutMessage': defaultToConfig2,
|
|
73
75
|
'withCredentials': defaultToConfig2,
|
|
76
|
+
'withXSRFToken': defaultToConfig2,
|
|
74
77
|
'adapter': defaultToConfig2,
|
|
75
78
|
'responseType': defaultToConfig2,
|
|
76
79
|
'xsrfCookieName': defaultToConfig2,
|
|
@@ -8,14 +8,15 @@ var defaults = require('../defaults');
|
|
|
8
8
|
*
|
|
9
9
|
* @param {Object|String} data The data to be transformed
|
|
10
10
|
* @param {Array} headers The headers for the request or response
|
|
11
|
+
* @param {Number} status HTTP status code
|
|
11
12
|
* @param {Array|Function} fns A single function or Array of functions
|
|
12
13
|
* @returns {*} The resulting transformed data
|
|
13
14
|
*/
|
|
14
|
-
module.exports = function transformData(data, headers, fns) {
|
|
15
|
+
module.exports = function transformData(data, headers, status, fns) {
|
|
15
16
|
var context = this || defaults;
|
|
16
17
|
/*eslint no-param-reassign:0*/
|
|
17
18
|
utils.forEach(fns, function transform(fn) {
|
|
18
|
-
data = fn.call(context, data, headers);
|
|
19
|
+
data = fn.call(context, data, headers, status);
|
|
19
20
|
});
|
|
20
21
|
|
|
21
22
|
return data;
|
|
@@ -5,6 +5,9 @@ var normalizeHeaderName = require('../helpers/normalizeHeaderName');
|
|
|
5
5
|
var AxiosError = require('../core/AxiosError');
|
|
6
6
|
var transitionalDefaults = require('./transitional');
|
|
7
7
|
var toFormData = require('../helpers/toFormData');
|
|
8
|
+
var toURLEncodedForm = require('../helpers/toURLEncodedForm');
|
|
9
|
+
var platform = require('../platform');
|
|
10
|
+
var formDataToJSON = require('../helpers/formDataToJSON');
|
|
8
11
|
|
|
9
12
|
var DEFAULT_CONTENT_TYPE = {
|
|
10
13
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
@@ -53,8 +56,21 @@ var defaults = {
|
|
|
53
56
|
normalizeHeaderName(headers, 'Accept');
|
|
54
57
|
normalizeHeaderName(headers, 'Content-Type');
|
|
55
58
|
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
var contentType = headers && headers['Content-Type'] || '';
|
|
60
|
+
var hasJSONContentType = contentType.indexOf('application/json') > -1;
|
|
61
|
+
var isObjectPayload = utils.isObject(data);
|
|
62
|
+
|
|
63
|
+
if (isObjectPayload && utils.isHTMLForm(data)) {
|
|
64
|
+
data = new FormData(data);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
var isFormData = utils.isFormData(data);
|
|
68
|
+
|
|
69
|
+
if (isFormData) {
|
|
70
|
+
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (utils.isArrayBuffer(data) ||
|
|
58
74
|
utils.isBuffer(data) ||
|
|
59
75
|
utils.isStream(data) ||
|
|
60
76
|
utils.isFile(data) ||
|
|
@@ -70,15 +86,25 @@ var defaults = {
|
|
|
70
86
|
return data.toString();
|
|
71
87
|
}
|
|
72
88
|
|
|
73
|
-
var isObjectPayload = utils.isObject(data);
|
|
74
|
-
var contentType = headers && headers['Content-Type'];
|
|
75
|
-
|
|
76
89
|
var isFileList;
|
|
77
90
|
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
91
|
+
if (isObjectPayload) {
|
|
92
|
+
if (contentType.indexOf('application/x-www-form-urlencoded') !== -1) {
|
|
93
|
+
return toURLEncodedForm(data, this.formSerializer).toString();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
|
|
97
|
+
var _FormData = this.env && this.env.FormData;
|
|
98
|
+
|
|
99
|
+
return toFormData(
|
|
100
|
+
isFileList ? {'files[]': data} : data,
|
|
101
|
+
_FormData && new _FormData(),
|
|
102
|
+
this.formSerializer
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (isObjectPayload || hasJSONContentType ) {
|
|
82
108
|
setContentTypeIfUnset(headers, 'application/json');
|
|
83
109
|
return stringifySafely(data);
|
|
84
110
|
}
|
|
@@ -88,11 +114,13 @@ var defaults = {
|
|
|
88
114
|
|
|
89
115
|
transformResponse: [function transformResponse(data) {
|
|
90
116
|
var transitional = this.transitional || defaults.transitional;
|
|
91
|
-
var silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
92
117
|
var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
|
|
93
|
-
var
|
|
118
|
+
var JSONRequested = this.responseType === 'json';
|
|
119
|
+
|
|
120
|
+
if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
|
|
121
|
+
var silentJSONParsing = transitional && transitional.silentJSONParsing;
|
|
122
|
+
var strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
94
123
|
|
|
95
|
-
if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
|
|
96
124
|
try {
|
|
97
125
|
return JSON.parse(data);
|
|
98
126
|
} catch (e) {
|
|
@@ -121,7 +149,8 @@ var defaults = {
|
|
|
121
149
|
maxBodyLength: -1,
|
|
122
150
|
|
|
123
151
|
env: {
|
|
124
|
-
FormData:
|
|
152
|
+
FormData: platform.classes.FormData,
|
|
153
|
+
Blob: platform.classes.Blob
|
|
125
154
|
},
|
|
126
155
|
|
|
127
156
|
validateStatus: function validateStatus(status) {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var toFormData = require('./toFormData');
|
|
4
|
+
|
|
5
|
+
function encode(str) {
|
|
6
|
+
var charMap = {
|
|
7
|
+
'!': '%21',
|
|
8
|
+
"'": '%27',
|
|
9
|
+
'(': '%28',
|
|
10
|
+
')': '%29',
|
|
11
|
+
'~': '%7E',
|
|
12
|
+
'%20': '+',
|
|
13
|
+
'%00': '\x00'
|
|
14
|
+
};
|
|
15
|
+
return encodeURIComponent(str).replace(/[!'\(\)~]|%20|%00/g, function replacer(match) {
|
|
16
|
+
return charMap[match];
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function AxiosURLSearchParams(params, options) {
|
|
21
|
+
this._pairs = [];
|
|
22
|
+
|
|
23
|
+
params && toFormData(params, this, options);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var prototype = AxiosURLSearchParams.prototype;
|
|
27
|
+
|
|
28
|
+
prototype.append = function append(name, value) {
|
|
29
|
+
this._pairs.push([name, value]);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
prototype.toString = function toString(encoder) {
|
|
33
|
+
var _encode = encoder ? function(value) {
|
|
34
|
+
return encoder.call(this, value, encode);
|
|
35
|
+
} : encode;
|
|
36
|
+
|
|
37
|
+
return this._pairs.map(function each(pair) {
|
|
38
|
+
return _encode(pair[0]) + '=' + _encode(pair[1]);
|
|
39
|
+
}, '').join('&');
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
module.exports = AxiosURLSearchParams;
|
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
module.exports = function bind(fn, thisArg) {
|
|
4
4
|
return function wrap() {
|
|
5
|
-
|
|
6
|
-
for (var i = 0; i < args.length; i++) {
|
|
7
|
-
args[i] = arguments[i];
|
|
8
|
-
}
|
|
9
|
-
return fn.apply(thisArg, args);
|
|
5
|
+
return fn.apply(thisArg, arguments);
|
|
10
6
|
};
|
|
11
7
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var utils = require('
|
|
3
|
+
var utils = require('../utils');
|
|
4
|
+
var AxiosURLSearchParams = require('../helpers/AxiosURLSearchParams');
|
|
4
5
|
|
|
5
6
|
function encode(val) {
|
|
6
7
|
return encodeURIComponent(val).
|
|
@@ -17,52 +18,36 @@ function encode(val) {
|
|
|
17
18
|
*
|
|
18
19
|
* @param {string} url The base of the url (e.g., http://www.google.com)
|
|
19
20
|
* @param {object} [params] The params to be appended
|
|
21
|
+
* @param {?object} options
|
|
20
22
|
* @returns {string} The formatted url
|
|
21
23
|
*/
|
|
22
|
-
module.exports = function buildURL(url, params,
|
|
24
|
+
module.exports = function buildURL(url, params, options) {
|
|
23
25
|
/*eslint no-param-reassign:0*/
|
|
24
26
|
if (!params) {
|
|
25
27
|
return url;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
var
|
|
29
|
-
if (paramsSerializer) {
|
|
30
|
-
serializedParams = paramsSerializer(params);
|
|
31
|
-
} else if (utils.isURLSearchParams(params)) {
|
|
32
|
-
serializedParams = params.toString();
|
|
33
|
-
} else {
|
|
34
|
-
var parts = [];
|
|
30
|
+
var hashmarkIndex = url.indexOf('#');
|
|
35
31
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
32
|
+
if (hashmarkIndex !== -1) {
|
|
33
|
+
url = url.slice(0, hashmarkIndex);
|
|
34
|
+
}
|
|
40
35
|
|
|
41
|
-
|
|
42
|
-
key = key + '[]';
|
|
43
|
-
} else {
|
|
44
|
-
val = [val];
|
|
45
|
-
}
|
|
36
|
+
var _encode = options && options.encode || encode;
|
|
46
37
|
|
|
47
|
-
|
|
48
|
-
if (utils.isDate(v)) {
|
|
49
|
-
v = v.toISOString();
|
|
50
|
-
} else if (utils.isObject(v)) {
|
|
51
|
-
v = JSON.stringify(v);
|
|
52
|
-
}
|
|
53
|
-
parts.push(encode(key) + '=' + encode(v));
|
|
54
|
-
});
|
|
55
|
-
});
|
|
38
|
+
var serializeFn = options && options.serialize;
|
|
56
39
|
|
|
57
|
-
|
|
40
|
+
var serializedParams;
|
|
41
|
+
|
|
42
|
+
if (serializeFn) {
|
|
43
|
+
serializedParams = serializeFn(params, options);
|
|
44
|
+
} else {
|
|
45
|
+
serializedParams = utils.isURLSearchParams(params) ?
|
|
46
|
+
params.toString() :
|
|
47
|
+
new AxiosURLSearchParams(params, options).toString(_encode);
|
|
58
48
|
}
|
|
59
49
|
|
|
60
50
|
if (serializedParams) {
|
|
61
|
-
var hashmarkIndex = url.indexOf('#');
|
|
62
|
-
if (hashmarkIndex !== -1) {
|
|
63
|
-
url = url.slice(0, hashmarkIndex);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
51
|
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
|
67
52
|
}
|
|
68
53
|
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('../utils');
|
|
4
|
+
|
|
5
|
+
function parsePropPath(name) {
|
|
6
|
+
// foo[x][y][z]
|
|
7
|
+
// foo.x.y.z
|
|
8
|
+
// foo-x-y-z
|
|
9
|
+
// foo x y z
|
|
10
|
+
return utils.matchAll(/\w+|\[(\w*)]/g, name).map(function(match) {
|
|
11
|
+
return match[0] === '[]' ? '' : match[1] || match[0];
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function arrayToObject(arr) {
|
|
16
|
+
var obj = {};
|
|
17
|
+
var keys = Object.keys(arr);
|
|
18
|
+
var i;
|
|
19
|
+
var len = keys.length;
|
|
20
|
+
var key;
|
|
21
|
+
for (i = 0; i < len; i++) {
|
|
22
|
+
key = keys[i];
|
|
23
|
+
obj[key] = arr[key];
|
|
24
|
+
}
|
|
25
|
+
return obj;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function formDataToJSON(formData) {
|
|
29
|
+
function buildPath(path, value, target, index) {
|
|
30
|
+
var name = path[index++];
|
|
31
|
+
|
|
32
|
+
if (name === '__proto__') return true;
|
|
33
|
+
|
|
34
|
+
var isNumericKey = Number.isFinite(+name);
|
|
35
|
+
var isLast = index >= path.length;
|
|
36
|
+
name = !name && utils.isArray(target) ? target.length : name;
|
|
37
|
+
|
|
38
|
+
if (isLast) {
|
|
39
|
+
if (utils.hasOwnProperty(target, name)) {
|
|
40
|
+
target[name] = [target[name], value];
|
|
41
|
+
} else {
|
|
42
|
+
target[name] = value;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return !isNumericKey;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (!target[name] || !utils.isObject(target[name])) {
|
|
49
|
+
target[name] = [];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var result = buildPath(path, value, target[name], index);
|
|
53
|
+
|
|
54
|
+
if (result && utils.isArray(target[name])) {
|
|
55
|
+
target[name] = arrayToObject(target[name]);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return !isNumericKey;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {
|
|
62
|
+
var obj = {};
|
|
63
|
+
|
|
64
|
+
utils.forEachEntry(formData, function(name, value) {
|
|
65
|
+
buildPath(parsePropPath(name), value, obj, 0);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return obj;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
module.exports = formDataToJSON;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var AxiosError = require('../core/AxiosError');
|
|
4
|
+
var parseProtocol = require('./parseProtocol');
|
|
5
|
+
var platform = require('../platform');
|
|
6
|
+
|
|
7
|
+
var DATA_URL_PATTERN = /^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Parse data uri to a Buffer or Blob
|
|
11
|
+
* @param {String} uri
|
|
12
|
+
* @param {?Boolean} asBlob
|
|
13
|
+
* @param {?Object} options
|
|
14
|
+
* @param {?Function} options.Blob
|
|
15
|
+
* @returns {Buffer|Blob}
|
|
16
|
+
*/
|
|
17
|
+
module.exports = function fromDataURI(uri, asBlob, options) {
|
|
18
|
+
var _Blob = options && options.Blob || platform.classes.Blob;
|
|
19
|
+
var protocol = parseProtocol(uri);
|
|
20
|
+
|
|
21
|
+
if (asBlob === undefined && _Blob) {
|
|
22
|
+
asBlob = true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (protocol === 'data') {
|
|
26
|
+
uri = protocol.length ? uri.slice(protocol.length + 1) : uri;
|
|
27
|
+
|
|
28
|
+
var match = DATA_URL_PATTERN.exec(uri);
|
|
29
|
+
|
|
30
|
+
if (!match) {
|
|
31
|
+
throw new AxiosError('Invalid URL', AxiosError.ERR_INVALID_URL);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
var mime = match[1];
|
|
35
|
+
var isBase64 = match[2];
|
|
36
|
+
var body = match[3];
|
|
37
|
+
var buffer = Buffer.from(decodeURIComponent(body), isBase64 ? 'base64' : 'utf8');
|
|
38
|
+
|
|
39
|
+
if (asBlob) {
|
|
40
|
+
if (!_Blob) {
|
|
41
|
+
throw new AxiosError('Blob is not supported', AxiosError.ERR_NOT_SUPPORT);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return new _Blob([buffer], {type: mime});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return buffer;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
throw new AxiosError('Unsupported protocol ' + protocol, AxiosError.ERR_NOT_SUPPORT);
|
|
51
|
+
};
|
|
@@ -13,16 +13,16 @@ module.exports = (
|
|
|
13
13
|
var originURL;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
* Parse a URL to discover it's components
|
|
17
|
+
*
|
|
18
|
+
* @param {String} url The URL to be parsed
|
|
19
|
+
* @returns {Object}
|
|
20
|
+
*/
|
|
21
21
|
function resolveURL(url) {
|
|
22
22
|
var href = url;
|
|
23
23
|
|
|
24
24
|
if (msie) {
|
|
25
|
-
|
|
25
|
+
// IE needs attribute set twice to normalize properties
|
|
26
26
|
urlParsingNode.setAttribute('href', href);
|
|
27
27
|
href = urlParsingNode.href;
|
|
28
28
|
}
|
|
@@ -47,11 +47,11 @@ module.exports = (
|
|
|
47
47
|
originURL = resolveURL(window.location.href);
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
* Determine if a URL shares the same origin as the current location
|
|
51
|
+
*
|
|
52
|
+
* @param {String} requestURL The URL to test
|
|
53
|
+
* @returns {boolean} True if URL shares the same origin, otherwise false
|
|
54
|
+
*/
|
|
55
55
|
return function isURLSameOrigin(requestURL) {
|
|
56
56
|
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
|
57
57
|
return (parsed.protocol === originURL.protocol &&
|
|
@@ -59,7 +59,7 @@ module.exports = (
|
|
|
59
59
|
};
|
|
60
60
|
})() :
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
// Non standard browser envs (web workers, react-native) lack needed support.
|
|
63
63
|
(function nonStandardBrowserEnv() {
|
|
64
64
|
return function isURLSameOrigin() {
|
|
65
65
|
return true;
|
|
@@ -34,8 +34,8 @@ module.exports = function parseHeaders(headers) {
|
|
|
34
34
|
|
|
35
35
|
utils.forEach(headers.split('\n'), function parser(line) {
|
|
36
36
|
i = line.indexOf(':');
|
|
37
|
-
key = utils.trim(line.
|
|
38
|
-
val = utils.trim(line.
|
|
37
|
+
key = utils.trim(line.slice(0, i)).toLowerCase();
|
|
38
|
+
val = utils.trim(line.slice(i + 1));
|
|
39
39
|
|
|
40
40
|
if (key) {
|
|
41
41
|
if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
|