The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 16:00 UTC
fix(shared): IPv6 SCP remotes match SSH repository identities (#36547)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Wout Stiens committed
Nov 14, 2026 at 09:03 UTC
294e061a2027fccbc1615a4c395f2031c2e18cb9
2 files changed
+21
-2
packages/shared/src/git.test.ts
+10
@@ -38,6 +38,16 @@ describe("normalizeGitRemoteUrl", () => {
38
);
39
});
40
41
+ it.each([
42
+ "git@[2001:db8::1]:team/repo.git",
43
+ "[2001:db8::1]:team/repo.git",
44
+ "git@[2001:DB8:0::1]:team/repo.git",
45
+ ])("canonicalizes an IPv6 SCP remote like its SSH URL: %s", (remote) => {
46
+ expect(normalizeGitRemoteUrl(remote)).toBe(
47
+ normalizeGitRemoteUrl("ssh://git@[2001:db8::1]/team/repo.git"),
48
+ );
49
+ });
50
+
51
it("preserves nested group paths for providers like GitLab", () => {
52
expect(normalizeGitRemoteUrl("git@gitlab.com:T3Tools/platform/T3Code.git")).toBe(
53
"gitlab.com/t3tools/platform/t3code",
packages/shared/src/git.ts
+11
-2
@@ -159,10 +159,19 @@ export function parseGitRemoteRepository(
159
// A userless one-letter prefix is a Windows drive, not an SCP host.
160
const scpStyleHostAndPath = /^[a-z]:/i.test(normalized)
161
? null
162
- : /^(?:[a-zA-Z0-9._-]+@)?([^@:/\\\s]+):\/?([^/\s]+(?:\/[^/\s]+)+)$/i.exec(normalized);
162
+ : /^(?:[a-zA-Z0-9._-]+@)?(\[[0-9a-f:.]+\]|[^@:/\\\s[\]]+):\/?([^/\s]+(?:\/[^/\s]+)+)$/i.exec(
163
+ normalized,
164
+ );
165
const scpHost = scpStyleHostAndPath?.[1];
166
const scpPath = scpStyleHostAndPath?.[2];
165
- return scpHost && scpPath ? { host: scpHost, path: scpPath } : null;
167
+ if (!scpHost || !scpPath) return null;
168
+ if (!scpHost.startsWith("[")) return { host: scpHost, path: scpPath };
169
+ try {
170
+ // Spell an IPv6 host as the URL branch does, so `[::1]:a/b` and `ssh://[::1]/a/b` share a key.
171
+ return { host: new URL(`ssh://${scpHost}`).hostname, path: scpPath };
172
+ } catch {
173
+ return null;
174
+ }
175
}
176
177
/**