mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +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
|
||||
if (
|
||||
request.status === 0 &&
|
||||
!(request.responseURL && request.responseURL.indexOf('file:') === 0)
|
||||
!(request.responseURL && request.responseURL.startsWith('file:'))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@@ -205,7 +205,7 @@ export default isXHRAdapterSupported &&
|
||||
|
||||
const protocol = parseProtocol(_config.url);
|
||||
|
||||
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
||||
if (protocol && !platform.protocols.includes(protocol)) {
|
||||
reject(
|
||||
new AxiosError(
|
||||
'Unsupported protocol ' + protocol + ':',
|
||||
|
||||
+4
-4
@@ -401,7 +401,7 @@ const isContextDefined = (context) => !isUndefined(context) && context !== _glob
|
||||
*
|
||||
* @returns {Object} Result of all merge properties
|
||||
*/
|
||||
function merge(/* obj1, obj2, obj3, ... */) {
|
||||
function merge(...objs) {
|
||||
const { caseless, skipUndefined } = (isContextDefined(this) && this) || {};
|
||||
const result = {};
|
||||
const assignValue = (val, key) => {
|
||||
@@ -422,8 +422,8 @@ function merge(/* obj1, obj2, obj3, ... */) {
|
||||
}
|
||||
};
|
||||
|
||||
for (let i = 0, l = arguments.length; i < l; i++) {
|
||||
arguments[i] && forEach(arguments[i], assignValue);
|
||||
for (let i = 0, l = objs.length; i < l; i++) {
|
||||
objs[i] && forEach(objs[i], assignValue);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -677,7 +677,7 @@ const reduceDescriptors = (obj, reducer) => {
|
||||
const freezeMethods = (obj) => {
|
||||
reduceDescriptors(obj, (descriptor, name) => {
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user