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
@matthewevans

Copy link
Copy Markdown
Member

Deferred by maintainer intake policy — not ignored.

This current head (bfc031af83f695a586d47c7f52472ff7ba82a071) was triaged as a frontend-only change (client/src/services/__tests__/serverDetection.test.ts, client/src/services/serverDetection.ts) by jeffrey701. The local frontend-review allowlist does not include this author, so this route does not perform an implementation-diff review or approve the PR.

A maintainer must explicitly take this PR or add a local frontend-review exception before it can receive substantive review. The defer label is a routing marker only, not a verdict on the change.

1 similar comment
@matthewevans

Copy link
Copy Markdown
Member

Deferred by maintainer intake policy — not ignored.

This current head (bfc031af83f695a586d47c7f52472ff7ba82a071) was triaged as a frontend-only change (client/src/services/__tests__/serverDetection.test.ts, client/src/services/serverDetection.ts) by jeffrey701. The local frontend-review allowlist does not include this author, so this route does not perform an implementation-diff review or approve the PR.

A maintainer must explicitly take this PR or add a local frontend-review exception before it can receive substantive review. The defer label is a routing marker only, not a verdict on the change.

@matthewevans matthewevans self-assigned this Aug 1, 2026
@matthewevans matthewevans added the bug Bug fix label Aug 1, 2026
@matthewevans matthewevans removed their assignment Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bug fix 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