mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
refactor: modernize utils and xhr adapter using ES6 features (#10588)
Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
+2
-2
@@ -91,7 +91,7 @@ export default isXHRAdapterSupported &&
|
|||||||
// will return status as 0 even though it's a successful request
|
// will return status as 0 even though it's a successful request
|
||||||
if (
|
if (
|
||||||
request.status === 0 &&
|
request.status === 0 &&
|
||||||
!(request.responseURL && request.responseURL.indexOf('file:') === 0)
|
!(request.responseURL && request.responseURL.startsWith('file:'))
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -205,7 +205,7 @@ export default isXHRAdapterSupported &&
|
|||||||
|
|
||||||
const protocol = parseProtocol(_config.url);
|
const protocol = parseProtocol(_config.url);
|
||||||
|
|
||||||
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
if (protocol && !platform.protocols.includes(protocol)) {
|
||||||
reject(
|
reject(
|
||||||
new AxiosError(
|
new AxiosError(
|
||||||
'Unsupported protocol ' + protocol + ':',
|
'Unsupported protocol ' + protocol + ':',
|
||||||
|
|||||||
+4
-4
@@ -401,7 +401,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
|
|||||||
*
|
*
|
||||||
* @returns {Object} Result of all merge properties
|
* @returns {Object} Result of all merge properties
|
||||||
*/
|
*/
|
||||||
function merge(/* obj1, obj2, obj3, ... */) {
|
function merge(...objs) {
|
||||||
const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
|
const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
|
||||||
const result = {};
|
const result = {};
|
||||||
const assignValue = (val, key) => {
|
const assignValue = (val, key) => {
|
||||||
@@ -422,8 +422,8 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
for (let i = 0, l = arguments.length; i < l; i++) {
|
for (let i = 0, l = objs.length; i < l; i++) {
|
||||||
arguments[i] && forEach(arguments[i], assignValue);
|
objs[i] && forEach(objs[i], assignValue);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -677,7 +677,7 @@ const reduceDescriptors = (obj, reducer) => {
|
|||||||
const freezeMethods = (obj) => {
|
const freezeMethods = (obj) => {
|
||||||
reduceDescriptors(obj, (descriptor, name) => {
|
reduceDescriptors(obj, (descriptor, name) => {
|
||||||
// skip restricted props in strict mode
|
// skip restricted props in strict mode
|
||||||
if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
|
if (isFunction(obj) && ['arguments', 'caller', 'callee'].includes(name)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user