Skip to content

refactor: modernize utils and xhr adapter using ES6 features#10588

Merged
jasonsaayman merged 3 commits intoaxios:v1.xfrom
singhankit001:refactor/modernize-utils-xhr
Apr 24, 2026
Merged

refactor: modernize utils and xhr adapter using ES6 features#10588
jasonsaayman merged 3 commits intoaxios:v1.xfrom
singhankit001:refactor/modernize-utils-xhr

Conversation

@singhankit001
Copy link
Copy Markdown
Contributor

@singhankit001 singhankit001 commented Mar 30, 2026

This PR modernizes several parts of the codebase by:

  1. Replacing arguments with rest parameters (...objs) in the merge function.
  2. Replacing indexOf(...) !== -1 with .includes(...) for better readability.
  3. Replacing indexOf(...) === 0 with .startsWith(...) in the XHR adapter.

These changes align with modern JavaScript standards already present in the Axios 1.x codebase.


Summary by cubic

Modernizes utils and the XHR adapter to ES6 (rest params, .includes, .startsWith) for clarity and consistency with v1.x. Synced with the latest v1.x; no behavior or API changes.

Description

  • Switched merge to rest params (keeps caseless/skipUndefined).
  • Replaced indexOf with .includes(...) across utils/XHR, including the restricted props check in freezeMethods.
  • Used .startsWith('file:') for file: URL detection; protocol allowlist now uses .includes(...).
  • Docs: no user-facing changes; consider updating /docs/ coding standards to prefer ES6 patterns.
  • Semantic version impact: patch (refactor only).

Testing

  • No tests changed; existing tests for XHR protocol handling and utils.merge are sufficient.

Written for commit 02dd117. Summary will update on new commits.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@singhankit001
Copy link
Copy Markdown
Contributor Author

singhankit001 commented Mar 31, 2026 via email

@jasonsaayman jasonsaayman self-requested a review as a code owner April 24, 2026 17:32
@jasonsaayman jasonsaayman added priority::medium A medium priority commit::refactor The PR is related to refactoring labels Apr 24, 2026
Copy link
Copy Markdown
Member

@jasonsaayman jasonsaayman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution, nicely done 🔥

@jasonsaayman jasonsaayman merged commit 767b975 into axios:v1.x Apr 24, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commit::refactor The PR is related to refactoring priority::medium A medium priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants