fix: use colon count instead of IPv6 regex for port-stripping guard#539
Merged
torlando-tech merged 1 commit intomainfrom Feb 24, 2026
Merged
fix: use colon count instead of IPv6 regex for port-stripping guard#539torlando-tech merged 1 commit intomainfrom
torlando-tech merged 1 commit intomainfrom
Conversation
Compressed IPv6 like "::1" or "fe80::1" aren't matched by IPV6_REGEX and would be corrupted by port stripping. Instead of fixing the regex, use a simpler invariant: IPv6 always has multiple colons, hostname:port has exactly one. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Greptile SummaryReplaces complex IPv6 regex checking with a simpler colon-counting approach to prevent port stripping from corrupting compressed IPv6 addresses like Key improvements:
Impact:
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: acc5324 |
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Summary
!IPV6_REGEX.matches()guard with a colon-count check (colonCount == 1) for port stripping invalidateHostname()::1andfe80::1aren't matched by the existingIPV6_REGEX, so they were being corrupted by the port-stripping logichostname:porthas exactly oneFollow-up to #537 addressing Greptile review feedback on #538.
Test plan
validateHostname - does not strip segments from IPv6 address(full-form)validateHostname - does not corrupt compressed IPv6 addresses(::1,fe80::1)🤖 Generated with Claude Code