Skip to content

fix(parseProtocol): fix regex to require colon in protocol separator#10729

Merged
jasonsaayman merged 2 commits intoaxios:v1.xfrom
deepview-autofix:deepview/46fc78298f
Apr 25, 2026
Merged

fix(parseProtocol): fix regex to require colon in protocol separator#10729
jasonsaayman merged 2 commits intoaxios:v1.xfrom
deepview-autofix:deepview/46fc78298f

Conversation

@deepview-autofix
Copy link
Copy Markdown
Contributor

@deepview-autofix deepview-autofix commented Apr 15, 2026

The regex used (:?\/\/|:) where :? was intended to be a non-capturing group (?: but instead made the colon an optional literal character. This caused URLs without a colon separator like http//example.com to incorrectly match and return http as the protocol. Fix the regex to :(?:\/\/)? which requires the colon and optionally matches //, correctly rejecting malformed URLs.


Summary by cubic

Fixes the parseProtocol regex to require a colon before the separator. This prevents false positives like http//example.com and does not affect valid URLs.

Description

  • Replace pattern (:?\/\/|:) with :(?:\/\/)? in parseProtocol.
  • Add a unit test asserting inputs without : don't match.
  • Merged latest v1.x with no behavior changes.

Docs

No docs changes needed.

Testing

  • Added test: http//example.com returns an empty string.
  • Existing tests unchanged.

Semantic version impact

Patch: bug fix with no API or behavior changes for valid inputs.

Written for commit 079fe8f. Summary will update on new commits.

The regex used `(:?\/\/|:)` where `:?` was intended to be a
non-capturing group `(?:` but instead made the colon an optional
literal character. This caused URLs without a colon separator like
`http//example.com` to incorrectly match and return `http` as the
protocol. Fix the regex to `:(?:\/\/)?` which requires the colon
and optionally matches `//`, correctly rejecting malformed URLs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: DeepView Autofix <276251120+deepview-autofix@users.noreply.github.com>
Co-Authored-By: Nikita Skovoroda <chalkerx@gmail.com>
Signed-off-by: Nikita Skovoroda <chalkerx@gmail.com>
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.

@jasonsaayman jasonsaayman self-requested a review as a code owner April 25, 2026 16:24
@jasonsaayman jasonsaayman added priority::medium A medium priority commit::fix The PR is related to a bugfix labels Apr 25, 2026
@jasonsaayman jasonsaayman merged commit f2dc449 into axios:v1.x Apr 25, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commit::fix The PR is related to a bugfix priority::medium A medium priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants