2
0
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:
Ankit Singh
2026-04-24 23:06:50 +05:30
committed by GitHub
parent e6a6241582
commit 767b975545
2 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -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
View File
@@ -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;
}