Fix IPv6 handling in siteAdapter (bracketed hosts, proxy path, cache keys) #349
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.
This PR should fix longstanding issues when running a wiki with IPv6 neighbors (e.g.
http://[::1]:4000) on Ubuntu and other systems with IPv6 enabled.Motivation
::1:4000hosts causedInvalid URLerrors in browsers andcurl./proxy/...without encoding."localhost", not::1or[::1].localForage(routes,withCredentials) were inconsistent:::1:3000vs[::1]:3000.getURL,getDirectURL, journal fixups) did brittle string surgery withsubstring(7).Changes
Add helpers:
normalizeSite,siteKey→ ensure canonical bracketed formhttpOriginFor,httpsOriginFor,proxyPathFor(encoded)isLoopbackSitedetection (supports::1,[::1], IPv4, localhost)Update
findAdapterQ:http://[::1]:port/...for loopbackReplace protocol-relative URLs (
//host/...) with explicit schemes.Replace string hacks with base reconstruction logic.
Canonicalize keys in
routeStoreandwithCredsStore.Clean up
findAdapter(proper arrow body).Use template strings for flag replacement consistently.
Testing
Local Test Farm setup with two wiki instances (ports 3000, 4000).
On Ubuntu with IPv6:
curl http://[::1]:4000/favicon.pngreturns 200curl http://localhost:3000/proxy/%5B::1%5D:4000/favicon.pngreturns 200Browser tests:
Verified flag replacement and journal/fork links resolve correctly.
Related
Checklist
findAdaptersyntax