Skip to content

feat: enhance parseRemoteAuthority to handle domains containing "--"#917

Open
ntoofu wants to merge 1 commit intocoder:mainfrom
ntoofu:domain-with-punycode
Open

feat: enhance parseRemoteAuthority to handle domains containing "--"#917
ntoofu wants to merge 1 commit intocoder:mainfrom
ntoofu:domain-with-punycode

Conversation

@ntoofu
Copy link
Copy Markdown

@ntoofu ntoofu commented Apr 23, 2026

Problem

As explained in CONTRIBUTING.md,

The host name takes the format coder-vscode.----.

The parser splits on "--" to extract each component, but domain labels may contain "--".
In practice, IDNA/Punycode-encoded domain labels use xn-- as the ACE prefix.
So the naive split("--") misparses hostnames with such labels, and causes errors like the following image.

Screenshot 2026-04-23 02-50-34

For example, a Coder deployment coder.xn--eckwd4c7cu47r2wf.jp would produce an SSH host of coder-vscode.coder.xn--eckwd4c7cu47r2wf.jp--yourname--your-workspace.
When split on "--", this yields ["coder-vscode.coder.xn", "eckwd4c7cu47r2wf.jp", "yourname", "your-workspace"] but the parser expects the first element to be the full hostname, so vscode-coder would try to open a workspace yourname whose owner is eckwd4c7cu47r2wf.jp and fails.

Solution

Added a reassembly step after the initial split("--").
The algorithm scans from the front of the split result:

  • The first segment is always a part of a hostname.
  • If the second segment contains a dot, that must be a fragmented part of a hostname. So merge those two segments back with "--".
  • Because more than one domain labels may contain "--", repeat this merging process until a dot does not appear in the second segment.

This works because Coder usernames never contain dots,
so any dot-bearing segment after the split must be a hostname fragment.

Note: a TLD containing "--" would not be handled correctly because such hostname would fragment into segments the last of which does not contain dot, but no such TLD exists today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant