fix(parseProtocol): fix regex to require colon in protocol separator#10729
Merged
jasonsaayman merged 2 commits intoaxios:v1.xfrom Apr 25, 2026
Merged
fix(parseProtocol): fix regex to require colon in protocol separator#10729jasonsaayman merged 2 commits intoaxios:v1.xfrom
jasonsaayman merged 2 commits intoaxios:v1.xfrom
Conversation
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>
jasonsaayman
approved these changes
Apr 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 likehttp//example.comto incorrectly match and returnhttpas the protocol. Fix the regex to:(?:\/\/)?which requires the colon and optionally matches//, correctly rejecting malformed URLs.Summary by cubic
Fixes the
parseProtocolregex to require a colon before the separator. This prevents false positives likehttp//example.comand does not affect valid URLs.Description
(:?\/\/|:)with:(?:\/\/)?inparseProtocol.:don't match.v1.xwith no behavior changes.Docs
No docs changes needed.
Testing
http//example.comreturns an empty string.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.