nw-app-build 99.99.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of nw-app-build might be problematic. Click here for more details.
- package/README.md +5 -0
- package/config/dev.env.js +37 -0
- package/config/hap.amend.js +29 -0
- package/config/index.js +8 -0
- package/config/prod.env.js +28 -0
- package/index.d.ts +130 -0
- package/index.js +1 -0
- package/package.json +47 -0
- package/src/index.html +12 -0
- package/src/lib/app.js +103 -0
- package/src/lib/axios/CHANGELOG.md +245 -0
- package/src/lib/axios/LICENSE +19 -0
- package/src/lib/axios/README.md +625 -0
- package/src/lib/axios/UPGRADE_GUIDE.md +162 -0
- package/src/lib/axios/dist/axios.js +1603 -0
- package/src/lib/axios/dist/axios.map +1 -0
- package/src/lib/axios/dist/axios.min.js +9 -0
- package/src/lib/axios/dist/axios.min.map +1 -0
- package/src/lib/axios/index.d.ts +131 -0
- package/src/lib/axios/index.js +1 -0
- package/src/lib/axios/lib/adapters/README.md +37 -0
- package/src/lib/axios/lib/adapters/http.js +237 -0
- package/src/lib/axios/lib/adapters/xhr.js +180 -0
- package/src/lib/axios/lib/axios.js +52 -0
- package/src/lib/axios/lib/cancel/Cancel.js +19 -0
- package/src/lib/axios/lib/cancel/CancelToken.js +57 -0
- package/src/lib/axios/lib/cancel/isCancel.js +5 -0
- package/src/lib/axios/lib/core/Axios.js +79 -0
- package/src/lib/axios/lib/core/InterceptorManager.js +52 -0
- package/src/lib/axios/lib/core/README.md +7 -0
- package/src/lib/axios/lib/core/createError.js +18 -0
- package/src/lib/axios/lib/core/dispatchRequest.js +86 -0
- package/src/lib/axios/lib/core/enhanceError.js +21 -0
- package/src/lib/axios/lib/core/settle.js +26 -0
- package/src/lib/axios/lib/core/transformData.js +20 -0
- package/src/lib/axios/lib/defaults.js +96 -0
- package/src/lib/axios/lib/helpers/README.md +7 -0
- package/src/lib/axios/lib/helpers/bind.js +11 -0
- package/src/lib/axios/lib/helpers/btoa.js +36 -0
- package/src/lib/axios/lib/helpers/buildURL.js +66 -0
- package/src/lib/axios/lib/helpers/combineURLs.js +14 -0
- package/src/lib/axios/lib/helpers/cookies.js +53 -0
- package/src/lib/axios/lib/helpers/deprecatedMethod.js +24 -0
- package/src/lib/axios/lib/helpers/isAbsoluteURL.js +14 -0
- package/src/lib/axios/lib/helpers/isURLSameOrigin.js +68 -0
- package/src/lib/axios/lib/helpers/normalizeHeaderName.js +12 -0
- package/src/lib/axios/lib/helpers/parseHeaders.js +53 -0
- package/src/lib/axios/lib/helpers/spread.js +27 -0
- package/src/lib/axios/lib/utils.js +303 -0
- package/src/lib/axios/modules/debug/CHANGELOG.md +395 -0
- package/src/lib/axios/modules/debug/LICENSE +19 -0
- package/src/lib/axios/modules/debug/README.md +437 -0
- package/src/lib/axios/modules/debug/dist/debug.js +886 -0
- package/src/lib/axios/modules/debug/node.js +1 -0
- package/src/lib/axios/modules/debug/package.json +96 -0
- package/src/lib/axios/modules/debug/src/browser.js +180 -0
- package/src/lib/axios/modules/debug/src/common.js +249 -0
- package/src/lib/axios/modules/debug/src/index.js +12 -0
- package/src/lib/axios/modules/debug/src/node.js +174 -0
- package/src/lib/axios/modules/follow-redirects/LICENSE +18 -0
- package/src/lib/axios/modules/follow-redirects/README.md +145 -0
- package/src/lib/axios/modules/follow-redirects/http.js +1 -0
- package/src/lib/axios/modules/follow-redirects/https.js +1 -0
- package/src/lib/axios/modules/follow-redirects/index.js +452 -0
- package/src/lib/axios/modules/follow-redirects/package.json +92 -0
- package/src/lib/axios/modules/is-buffer/LICENSE +21 -0
- package/src/lib/axios/modules/is-buffer/README.md +53 -0
- package/src/lib/axios/modules/is-buffer/index.js +21 -0
- package/src/lib/axios/modules/is-buffer/package.json +90 -0
- package/src/lib/axios/modules/is-buffer/test/basic.js +24 -0
- package/src/lib/axios/modules/ms/index.js +162 -0
- package/src/lib/axios/modules/ms/license.md +21 -0
- package/src/lib/axios/modules/ms/package.json +72 -0
- package/src/lib/axios/modules/ms/readme.md +60 -0
- package/src/lib/axios/package-lock.json +10437 -0
- package/src/lib/axios/package.json +111 -0
- package/src/lib/axios.min.js +10 -0
- package/src/lib/axiosRequest.js +84 -0
- package/src/lib/bmob.js +36 -0
- package/src/lib/common.js +227 -0
- package/src/lib/config.dev.js +62 -0
- package/src/lib/config.js +69 -0
- package/src/lib/dataType.js +17 -0
- package/src/lib/error.js +32 -0
- package/src/lib/file.js +250 -0
- package/src/lib/hapRequest.js +68 -0
- package/src/lib/hapStorage.js +62 -0
- package/src/lib/init.js +0 -0
- package/src/lib/nodestorage.js +14 -0
- package/src/lib/pay.js +19 -0
- package/src/lib/pointer.js +18 -0
- package/src/lib/query.js +689 -0
- package/src/lib/relation.js +45 -0
- package/src/lib/request.js +21 -0
- package/src/lib/sms.js +40 -0
- package/src/lib/socket.js +292 -0
- package/src/lib/storage.js +21 -0
- package/src/lib/user.js +225 -0
- package/src/lib/utf8md5.js +205 -0
- package/src/lib/utils.js +61 -0
- package/src/lib/webstorage.js +32 -0
- package/src/lib/wxRequest.js +88 -0
- package/src/lib/wxstorage.js +27 -0
- package/src/main.js +27 -0
- package/test/index.html +15 -0
- package/test/index.js +12 -0
- package/tsconfig.json +100 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var utils = require('./../utils');
|
4
|
+
|
5
|
+
function InterceptorManager() {
|
6
|
+
this.handlers = [];
|
7
|
+
}
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Add a new interceptor to the stack
|
11
|
+
*
|
12
|
+
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
13
|
+
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
14
|
+
*
|
15
|
+
* @return {Number} An ID used to remove interceptor later
|
16
|
+
*/
|
17
|
+
InterceptorManager.prototype.use = function use(fulfilled, rejected) {
|
18
|
+
this.handlers.push({
|
19
|
+
fulfilled: fulfilled,
|
20
|
+
rejected: rejected
|
21
|
+
});
|
22
|
+
return this.handlers.length - 1;
|
23
|
+
};
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Remove an interceptor from the stack
|
27
|
+
*
|
28
|
+
* @param {Number} id The ID that was returned by `use`
|
29
|
+
*/
|
30
|
+
InterceptorManager.prototype.eject = function eject(id) {
|
31
|
+
if (this.handlers[id]) {
|
32
|
+
this.handlers[id] = null;
|
33
|
+
}
|
34
|
+
};
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Iterate over all the registered interceptors
|
38
|
+
*
|
39
|
+
* This method is particularly useful for skipping over any
|
40
|
+
* interceptors that may have become `null` calling `eject`.
|
41
|
+
*
|
42
|
+
* @param {Function} fn The function to call for each interceptor
|
43
|
+
*/
|
44
|
+
InterceptorManager.prototype.forEach = function forEach(fn) {
|
45
|
+
utils.forEach(this.handlers, function forEachHandler(h) {
|
46
|
+
if (h !== null) {
|
47
|
+
fn(h);
|
48
|
+
}
|
49
|
+
});
|
50
|
+
};
|
51
|
+
|
52
|
+
module.exports = InterceptorManager;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# axios // core
|
2
|
+
|
3
|
+
The modules found in `core/` should be modules that are specific to the domain logic of axios. These modules would most likely not make sense to be consumed outside of the axios module, as their logic is too specific. Some examples of core modules are:
|
4
|
+
|
5
|
+
- Dispatching requests
|
6
|
+
- Managing interceptors
|
7
|
+
- Handling config
|
@@ -0,0 +1,18 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var enhanceError = require('./enhanceError');
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Create an Error with the specified message, config, error code, request and response.
|
7
|
+
*
|
8
|
+
* @param {string} message The error message.
|
9
|
+
* @param {Object} config The config.
|
10
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
11
|
+
* @param {Object} [request] The request.
|
12
|
+
* @param {Object} [response] The response.
|
13
|
+
* @returns {Error} The created error.
|
14
|
+
*/
|
15
|
+
module.exports = function createError(message, config, code, request, response) {
|
16
|
+
var error = new Error(message);
|
17
|
+
return enhanceError(error, config, code, request, response);
|
18
|
+
};
|
@@ -0,0 +1,86 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var utils = require('./../utils');
|
4
|
+
var transformData = require('./transformData');
|
5
|
+
var isCancel = require('../cancel/isCancel');
|
6
|
+
var defaults = require('../defaults');
|
7
|
+
var isAbsoluteURL = require('./../helpers/isAbsoluteURL');
|
8
|
+
var combineURLs = require('./../helpers/combineURLs');
|
9
|
+
|
10
|
+
/**
|
11
|
+
* Throws a `Cancel` if cancellation has been requested.
|
12
|
+
*/
|
13
|
+
function throwIfCancellationRequested(config) {
|
14
|
+
if (config.cancelToken) {
|
15
|
+
config.cancelToken.throwIfRequested();
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Dispatch a request to the server using the configured adapter.
|
21
|
+
*
|
22
|
+
* @param {object} config The config that is to be used for the request
|
23
|
+
* @returns {Promise} The Promise to be fulfilled
|
24
|
+
*/
|
25
|
+
module.exports = function dispatchRequest(config) {
|
26
|
+
throwIfCancellationRequested(config);
|
27
|
+
|
28
|
+
// Support baseURL config
|
29
|
+
if (config.baseURL && !isAbsoluteURL(config.url)) {
|
30
|
+
config.url = combineURLs(config.baseURL, config.url);
|
31
|
+
}
|
32
|
+
|
33
|
+
// Ensure headers exist
|
34
|
+
config.headers = config.headers || {};
|
35
|
+
|
36
|
+
// Transform request data
|
37
|
+
config.data = transformData(
|
38
|
+
config.data,
|
39
|
+
config.headers,
|
40
|
+
config.transformRequest
|
41
|
+
);
|
42
|
+
|
43
|
+
// Flatten headers
|
44
|
+
config.headers = utils.merge(
|
45
|
+
config.headers.common || {},
|
46
|
+
config.headers[config.method] || {},
|
47
|
+
config.headers || {}
|
48
|
+
);
|
49
|
+
|
50
|
+
utils.forEach(
|
51
|
+
['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
|
52
|
+
function cleanHeaderConfig(method) {
|
53
|
+
delete config.headers[method];
|
54
|
+
}
|
55
|
+
);
|
56
|
+
|
57
|
+
var adapter = config.adapter || defaults.adapter;
|
58
|
+
|
59
|
+
return adapter(config).then(function onAdapterResolution(response) {
|
60
|
+
throwIfCancellationRequested(config);
|
61
|
+
|
62
|
+
// Transform response data
|
63
|
+
response.data = transformData(
|
64
|
+
response.data,
|
65
|
+
response.headers,
|
66
|
+
config.transformResponse
|
67
|
+
);
|
68
|
+
|
69
|
+
return response;
|
70
|
+
}, function onAdapterRejection(reason) {
|
71
|
+
if (!isCancel(reason)) {
|
72
|
+
throwIfCancellationRequested(config);
|
73
|
+
|
74
|
+
// Transform response data
|
75
|
+
if (reason && reason.response) {
|
76
|
+
reason.response.data = transformData(
|
77
|
+
reason.response.data,
|
78
|
+
reason.response.headers,
|
79
|
+
config.transformResponse
|
80
|
+
);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
return Promise.reject(reason);
|
85
|
+
});
|
86
|
+
};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Update an Error with the specified config, error code, and response.
|
5
|
+
*
|
6
|
+
* @param {Error} error The error to update.
|
7
|
+
* @param {Object} config The config.
|
8
|
+
* @param {string} [code] The error code (for example, 'ECONNABORTED').
|
9
|
+
* @param {Object} [request] The request.
|
10
|
+
* @param {Object} [response] The response.
|
11
|
+
* @returns {Error} The error.
|
12
|
+
*/
|
13
|
+
module.exports = function enhanceError(error, config, code, request, response) {
|
14
|
+
error.config = config;
|
15
|
+
if (code) {
|
16
|
+
error.code = code;
|
17
|
+
}
|
18
|
+
error.request = request;
|
19
|
+
error.response = response;
|
20
|
+
return error;
|
21
|
+
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var createError = require('./createError');
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Resolve or reject a Promise based on response status.
|
7
|
+
*
|
8
|
+
* @param {Function} resolve A function that resolves the promise.
|
9
|
+
* @param {Function} reject A function that rejects the promise.
|
10
|
+
* @param {object} response The response.
|
11
|
+
*/
|
12
|
+
module.exports = function settle(resolve, reject, response) {
|
13
|
+
var validateStatus = response.config.validateStatus;
|
14
|
+
// Note: status is not exposed by XDomainRequest
|
15
|
+
if (!response.status || !validateStatus || validateStatus(response.status)) {
|
16
|
+
resolve(response);
|
17
|
+
} else {
|
18
|
+
reject(createError(
|
19
|
+
'Request failed with status code ' + response.status,
|
20
|
+
response.config,
|
21
|
+
null,
|
22
|
+
response.request,
|
23
|
+
response
|
24
|
+
));
|
25
|
+
}
|
26
|
+
};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var utils = require('./../utils');
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Transform the data for a request or a response
|
7
|
+
*
|
8
|
+
* @param {Object|String} data The data to be transformed
|
9
|
+
* @param {Array} headers The headers for the request or response
|
10
|
+
* @param {Array|Function} fns A single function or Array of functions
|
11
|
+
* @returns {*} The resulting transformed data
|
12
|
+
*/
|
13
|
+
module.exports = function transformData(data, headers, fns) {
|
14
|
+
/*eslint no-param-reassign:0*/
|
15
|
+
utils.forEach(fns, function transform(fn) {
|
16
|
+
data = fn(data, headers);
|
17
|
+
});
|
18
|
+
|
19
|
+
return data;
|
20
|
+
};
|
@@ -0,0 +1,96 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var utils = require('./utils');
|
4
|
+
var normalizeHeaderName = require('./helpers/normalizeHeaderName');
|
5
|
+
|
6
|
+
var DEFAULT_CONTENT_TYPE = {
|
7
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
8
|
+
};
|
9
|
+
|
10
|
+
function setContentTypeIfUnset(headers, value) {
|
11
|
+
if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
|
12
|
+
headers['Content-Type'] = value;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
function getDefaultAdapter() {
|
17
|
+
var adapter;
|
18
|
+
if (typeof XMLHttpRequest !== 'undefined') {
|
19
|
+
// For browsers use XHR adapter
|
20
|
+
adapter = require('./adapters/xhr');
|
21
|
+
} else if (typeof process !== 'undefined') {
|
22
|
+
// For node use HTTP adapter
|
23
|
+
adapter = require('./adapters/http');
|
24
|
+
}
|
25
|
+
return adapter;
|
26
|
+
}
|
27
|
+
|
28
|
+
var defaults = {
|
29
|
+
adapter: getDefaultAdapter(),
|
30
|
+
|
31
|
+
transformRequest: [function transformRequest(data, headers) {
|
32
|
+
normalizeHeaderName(headers, 'Content-Type');
|
33
|
+
if (utils.isFormData(data) ||
|
34
|
+
utils.isArrayBuffer(data) ||
|
35
|
+
utils.isBuffer(data) ||
|
36
|
+
utils.isStream(data) ||
|
37
|
+
utils.isFile(data) ||
|
38
|
+
utils.isBlob(data)
|
39
|
+
) {
|
40
|
+
return data;
|
41
|
+
}
|
42
|
+
if (utils.isArrayBufferView(data)) {
|
43
|
+
return data.buffer;
|
44
|
+
}
|
45
|
+
if (utils.isURLSearchParams(data)) {
|
46
|
+
setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
|
47
|
+
return data.toString();
|
48
|
+
}
|
49
|
+
if (utils.isObject(data)) {
|
50
|
+
setContentTypeIfUnset(headers, 'application/json;charset=utf-8');
|
51
|
+
return JSON.stringify(data);
|
52
|
+
}
|
53
|
+
return data;
|
54
|
+
}],
|
55
|
+
|
56
|
+
transformResponse: [function transformResponse(data) {
|
57
|
+
/*eslint no-param-reassign:0*/
|
58
|
+
if (typeof data === 'string') {
|
59
|
+
try {
|
60
|
+
data = JSON.parse(data);
|
61
|
+
} catch (e) { /* Ignore */ }
|
62
|
+
}
|
63
|
+
return data;
|
64
|
+
}],
|
65
|
+
|
66
|
+
/**
|
67
|
+
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
68
|
+
* timeout is not created.
|
69
|
+
*/
|
70
|
+
timeout: 0,
|
71
|
+
|
72
|
+
xsrfCookieName: 'XSRF-TOKEN',
|
73
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
74
|
+
|
75
|
+
maxContentLength: -1,
|
76
|
+
|
77
|
+
validateStatus: function validateStatus(status) {
|
78
|
+
return status >= 200 && status < 300;
|
79
|
+
}
|
80
|
+
};
|
81
|
+
|
82
|
+
defaults.headers = {
|
83
|
+
common: {
|
84
|
+
'Accept': 'application/json, text/plain, */*'
|
85
|
+
}
|
86
|
+
};
|
87
|
+
|
88
|
+
utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
|
89
|
+
defaults.headers[method] = {};
|
90
|
+
});
|
91
|
+
|
92
|
+
utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
|
93
|
+
defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
|
94
|
+
});
|
95
|
+
|
96
|
+
module.exports = defaults;
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# axios // helpers
|
2
|
+
|
3
|
+
The modules found in `helpers/` should be generic modules that are _not_ specific to the domain logic of axios. These modules could theoretically be published to npm on their own and consumed by other modules or apps. Some examples of generic modules are things like:
|
4
|
+
|
5
|
+
- Browser polyfills
|
6
|
+
- Managing cookies
|
7
|
+
- Parsing HTTP headers
|
@@ -0,0 +1,36 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
// btoa polyfill for IE<10 courtesy https://github.com/davidchambers/Base64.js
|
4
|
+
|
5
|
+
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
6
|
+
|
7
|
+
function E() {
|
8
|
+
this.message = 'String contains an invalid character';
|
9
|
+
}
|
10
|
+
E.prototype = new Error;
|
11
|
+
E.prototype.code = 5;
|
12
|
+
E.prototype.name = 'InvalidCharacterError';
|
13
|
+
|
14
|
+
function btoa(input) {
|
15
|
+
var str = String(input);
|
16
|
+
var output = '';
|
17
|
+
for (
|
18
|
+
// initialize result and counter
|
19
|
+
var block, charCode, idx = 0, map = chars;
|
20
|
+
// if the next str index does not exist:
|
21
|
+
// change the mapping table to "="
|
22
|
+
// check if d has no fractional digits
|
23
|
+
str.charAt(idx | 0) || (map = '=', idx % 1);
|
24
|
+
// "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
|
25
|
+
output += map.charAt(63 & block >> 8 - idx % 1 * 8)
|
26
|
+
) {
|
27
|
+
charCode = str.charCodeAt(idx += 3 / 4);
|
28
|
+
if (charCode > 0xFF) {
|
29
|
+
throw new E();
|
30
|
+
}
|
31
|
+
block = block << 8 | charCode;
|
32
|
+
}
|
33
|
+
return output;
|
34
|
+
}
|
35
|
+
|
36
|
+
module.exports = btoa;
|
@@ -0,0 +1,66 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var utils = require('./../utils');
|
4
|
+
|
5
|
+
function encode(val) {
|
6
|
+
return encodeURIComponent(val).
|
7
|
+
replace(/%40/gi, '@').
|
8
|
+
replace(/%3A/gi, ':').
|
9
|
+
replace(/%24/g, '$').
|
10
|
+
replace(/%2C/gi, ',').
|
11
|
+
replace(/%20/g, '+').
|
12
|
+
replace(/%5B/gi, '[').
|
13
|
+
replace(/%5D/gi, ']');
|
14
|
+
}
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Build a URL by appending params to the end
|
18
|
+
*
|
19
|
+
* @param {string} url The base of the url (e.g., http://www.google.com)
|
20
|
+
* @param {object} [params] The params to be appended
|
21
|
+
* @returns {string} The formatted url
|
22
|
+
*/
|
23
|
+
module.exports = function buildURL(url, params, paramsSerializer) {
|
24
|
+
/*eslint no-param-reassign:0*/
|
25
|
+
if (!params) {
|
26
|
+
return url;
|
27
|
+
}
|
28
|
+
|
29
|
+
var serializedParams;
|
30
|
+
if (paramsSerializer) {
|
31
|
+
serializedParams = paramsSerializer(params);
|
32
|
+
} else if (utils.isURLSearchParams(params)) {
|
33
|
+
serializedParams = params.toString();
|
34
|
+
} else {
|
35
|
+
var parts = [];
|
36
|
+
|
37
|
+
utils.forEach(params, function serialize(val, key) {
|
38
|
+
if (val === null || typeof val === 'undefined') {
|
39
|
+
return;
|
40
|
+
}
|
41
|
+
|
42
|
+
if (utils.isArray(val)) {
|
43
|
+
key = key + '[]';
|
44
|
+
} else {
|
45
|
+
val = [val];
|
46
|
+
}
|
47
|
+
|
48
|
+
utils.forEach(val, function parseValue(v) {
|
49
|
+
if (utils.isDate(v)) {
|
50
|
+
v = v.toISOString();
|
51
|
+
} else if (utils.isObject(v)) {
|
52
|
+
v = JSON.stringify(v);
|
53
|
+
}
|
54
|
+
parts.push(encode(key) + '=' + encode(v));
|
55
|
+
});
|
56
|
+
});
|
57
|
+
|
58
|
+
serializedParams = parts.join('&');
|
59
|
+
}
|
60
|
+
|
61
|
+
if (serializedParams) {
|
62
|
+
url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
|
63
|
+
}
|
64
|
+
|
65
|
+
return url;
|
66
|
+
};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Creates a new URL by combining the specified URLs
|
5
|
+
*
|
6
|
+
* @param {string} baseURL The base URL
|
7
|
+
* @param {string} relativeURL The relative URL
|
8
|
+
* @returns {string} The combined URL
|
9
|
+
*/
|
10
|
+
module.exports = function combineURLs(baseURL, relativeURL) {
|
11
|
+
return relativeURL
|
12
|
+
? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
|
13
|
+
: baseURL;
|
14
|
+
};
|
@@ -0,0 +1,53 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var utils = require('./../utils');
|
4
|
+
|
5
|
+
module.exports = (
|
6
|
+
utils.isStandardBrowserEnv() ?
|
7
|
+
|
8
|
+
// Standard browser envs support document.cookie
|
9
|
+
(function standardBrowserEnv() {
|
10
|
+
return {
|
11
|
+
write: function write(name, value, expires, path, domain, secure) {
|
12
|
+
var cookie = [];
|
13
|
+
cookie.push(name + '=' + encodeURIComponent(value));
|
14
|
+
|
15
|
+
if (utils.isNumber(expires)) {
|
16
|
+
cookie.push('expires=' + new Date(expires).toGMTString());
|
17
|
+
}
|
18
|
+
|
19
|
+
if (utils.isString(path)) {
|
20
|
+
cookie.push('path=' + path);
|
21
|
+
}
|
22
|
+
|
23
|
+
if (utils.isString(domain)) {
|
24
|
+
cookie.push('domain=' + domain);
|
25
|
+
}
|
26
|
+
|
27
|
+
if (secure === true) {
|
28
|
+
cookie.push('secure');
|
29
|
+
}
|
30
|
+
|
31
|
+
document.cookie = cookie.join('; ');
|
32
|
+
},
|
33
|
+
|
34
|
+
read: function read(name) {
|
35
|
+
var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
|
36
|
+
return (match ? decodeURIComponent(match[3]) : null);
|
37
|
+
},
|
38
|
+
|
39
|
+
remove: function remove(name) {
|
40
|
+
this.write(name, '', Date.now() - 86400000);
|
41
|
+
}
|
42
|
+
};
|
43
|
+
})() :
|
44
|
+
|
45
|
+
// Non standard browser env (web workers, react-native) lack needed support.
|
46
|
+
(function nonStandardBrowserEnv() {
|
47
|
+
return {
|
48
|
+
write: function write() {},
|
49
|
+
read: function read() { return null; },
|
50
|
+
remove: function remove() {}
|
51
|
+
};
|
52
|
+
})()
|
53
|
+
);
|
@@ -0,0 +1,24 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
/*eslint no-console:0*/
|
4
|
+
|
5
|
+
/**
|
6
|
+
* Supply a warning to the developer that a method they are using
|
7
|
+
* has been deprecated.
|
8
|
+
*
|
9
|
+
* @param {string} method The name of the deprecated method
|
10
|
+
* @param {string} [instead] The alternate method to use if applicable
|
11
|
+
* @param {string} [docs] The documentation URL to get further details
|
12
|
+
*/
|
13
|
+
module.exports = function deprecatedMethod(method, instead, docs) {
|
14
|
+
try {
|
15
|
+
console.warn(
|
16
|
+
'DEPRECATED method `' + method + '`.' +
|
17
|
+
(instead ? ' Use `' + instead + '` instead.' : '') +
|
18
|
+
' This method will be removed in a future release.');
|
19
|
+
|
20
|
+
if (docs) {
|
21
|
+
console.warn('For more information about usage see ' + docs);
|
22
|
+
}
|
23
|
+
} catch (e) { /* Ignore */ }
|
24
|
+
};
|
@@ -0,0 +1,14 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Determines whether the specified URL is absolute
|
5
|
+
*
|
6
|
+
* @param {string} url The URL to test
|
7
|
+
* @returns {boolean} True if the specified URL is absolute, otherwise false
|
8
|
+
*/
|
9
|
+
module.exports = function isAbsoluteURL(url) {
|
10
|
+
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
|
11
|
+
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
|
12
|
+
// by any combination of letters, digits, plus, period, or hyphen.
|
13
|
+
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
|
14
|
+
};
|
@@ -0,0 +1,68 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var utils = require('./../utils');
|
4
|
+
|
5
|
+
module.exports = (
|
6
|
+
utils.isStandardBrowserEnv() ?
|
7
|
+
|
8
|
+
// Standard browser envs have full support of the APIs needed to test
|
9
|
+
// whether the request URL is of the same origin as current location.
|
10
|
+
(function standardBrowserEnv() {
|
11
|
+
var msie = /(msie|trident)/i.test(navigator.userAgent);
|
12
|
+
var urlParsingNode = document.createElement('a');
|
13
|
+
var originURL;
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Parse a URL to discover it's components
|
17
|
+
*
|
18
|
+
* @param {String} url The URL to be parsed
|
19
|
+
* @returns {Object}
|
20
|
+
*/
|
21
|
+
function resolveURL(url) {
|
22
|
+
var href = url;
|
23
|
+
|
24
|
+
if (msie) {
|
25
|
+
// IE needs attribute set twice to normalize properties
|
26
|
+
urlParsingNode.setAttribute('href', href);
|
27
|
+
href = urlParsingNode.href;
|
28
|
+
}
|
29
|
+
|
30
|
+
urlParsingNode.setAttribute('href', href);
|
31
|
+
|
32
|
+
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
33
|
+
return {
|
34
|
+
href: urlParsingNode.href,
|
35
|
+
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
|
36
|
+
host: urlParsingNode.host,
|
37
|
+
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
|
38
|
+
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
|
39
|
+
hostname: urlParsingNode.hostname,
|
40
|
+
port: urlParsingNode.port,
|
41
|
+
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
|
42
|
+
urlParsingNode.pathname :
|
43
|
+
'/' + urlParsingNode.pathname
|
44
|
+
};
|
45
|
+
}
|
46
|
+
|
47
|
+
originURL = resolveURL(window.location.href);
|
48
|
+
|
49
|
+
/**
|
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
|
+
return function isURLSameOrigin(requestURL) {
|
56
|
+
var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
|
57
|
+
return (parsed.protocol === originURL.protocol &&
|
58
|
+
parsed.host === originURL.host);
|
59
|
+
};
|
60
|
+
})() :
|
61
|
+
|
62
|
+
// Non standard browser envs (web workers, react-native) lack needed support.
|
63
|
+
(function nonStandardBrowserEnv() {
|
64
|
+
return function isURLSameOrigin() {
|
65
|
+
return true;
|
66
|
+
};
|
67
|
+
})()
|
68
|
+
);
|
@@ -0,0 +1,12 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
var utils = require('../utils');
|
4
|
+
|
5
|
+
module.exports = function normalizeHeaderName(headers, normalizedName) {
|
6
|
+
utils.forEach(headers, function processHeader(value, name) {
|
7
|
+
if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
|
8
|
+
headers[normalizedName] = value;
|
9
|
+
delete headers[name];
|
10
|
+
}
|
11
|
+
});
|
12
|
+
};
|