Skip to content

fix(client): parse a port-less bracketed IPv6 host in parseJoinCode#5178

Open
jeffrey701 wants to merge 1 commit into
phase-rs:mainfrom
jeffrey701:fix/joincode-ipv6-host
Open

fix(client): parse a port-less bracketed IPv6 host in parseJoinCode#5178
jeffrey701 wants to merge 1 commit into
phase-rs:mainfrom
jeffrey701:fix/joincode-ipv6-host

Conversation

@jeffrey701

Copy link
Copy Markdown
Contributor

Problem

parseJoinCode (client/src/services/serverDetection.ts) splits host:port on the last colon:

const colonIndex = hostPort.lastIndexOf(":");
const hasPort = colonIndex !== -1 && colonIndex < hostPort.length - 1;
const host = hasPort ? hostPort.slice(0, colonIndex) : hostPort;

For a bracketed IPv6 literal with no port ([::1]), that last colon is inside the address, so host becomes "[:" and the join code ABC123@[::1] resolves to a malformed, unconnectable wss://[::1/ws.

Fix

A bracketed host with no port ends in ], so add !hostPort.endsWith("]") to the hasPort check. A bracketed host that does carry a port ([::1]:9000) does not end in ], so it still splits correctly.

Test

client/src/services/__tests__/serverDetection.test.ts[::1] resolves to wss://[::1]/ws, and [::1]:9000 still splits to wss://[::1]:9000/ws.

@jeffrey701 jeffrey701 requested a review from matthewevans as a code owner July 6, 2026 04:48
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

parseJoinCode splits host:port on the LAST colon. For a bracketed IPv6 literal
with no port (e.g. `[::1]`), that colon is inside the address, so the host
became `[:` and the join code resolved to a malformed `wss://[::1/ws`.
Treat a host ending in `]` as bracketed-with-no-port and skip the split; a
bracketed host that does carry a port (`[::1]:9000`) still splits correctly.
@jeffrey701 jeffrey701 force-pushed the fix/joincode-ipv6-host branch from 9c7738d to bfc031a Compare July 6, 2026 08:34
@matthewevans matthewevans added the defer-fe Frontend/client/UI PR deferred to Matt's direct review label Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

defer-fe Frontend/client/UI PR deferred to Matt's direct review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants