Repository navigation
fix: treat IPv4-mapped IPv6 loopback as localhost - #3255
Merged
Merged
Conversation
OrKoN
approved these changes
Oct 20, 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.
What
isLocalhostreturnedfalsefor IPv4-mapped IPv6 loopback addresses such asws://[::ffff:127.0.0.1]:9222.URLserializes that host as[::ffff:7f00:1], which matched neither the[::1]check nor the dotted IPv4 regex.isLocalBrowserinToolHandler.tsusesisLocalhoston the browser'swsEndpoint. So a browser that is reached on a mapped loopback address was treated as remote, and file verification used theremoteoption instead oflocal. Telemetry'sis_localhosthad the same problem.Fix
The check now also accepts hostnames matching
[::ffff:7fXX:XXXX], which is 127.0.0.0/8 in mapped form. Mapped non-loopback addresses ([::ffff:128.0.0.1],[::ffff:192.168.1.1]) still returnfalse.Tests
I added
should return true for IPv4-mapped IPv6 loopbacktotests/utils/url.test.ts. It fails before the change and passes after. I rantests/utils/url.test.ts(36 tests) with tsx against the source rather than doing a fullnpm run build. Prettier check passes.AI assistance: I used an AI coding assistant (Grok Bot) to help find and write this fix. I reviewed the change and ran the tests myself.