@devries-cameron20 / t3code Mirror · read-only / commits / f012aa6c47
Fork 0

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 22, 12:00 UTC

fix(github): drop a clone URL's .git before a trailing slash or query (#21325)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Victor Vogel committed Oct 30, 2026 at 15:25 UTC f012aa6c4712367dbe750f796e44ee6779c42e73
2 files changed +25 -3
packages/source-control-github/src/server/gitHubRepositoryResolution.test.ts
+20
@@ -80,6 +80,26 @@ describe("selectGitHubBaseRepository", () => {
80 });
81 });
82
83 +describe("parseGitHubRepositorySelector", () => {
84 + it("drops a clone URL's .git suffix wherever the selector ends", () => {
85 + for (const [selector, host, name] of [
86 + ["https://github.com/acme/web.git", "github.com", "web"],
87 + ["https://github.com/acme/web.git/", "github.com", "web"],
88 + ["https://github.com/acme/web.git?tab=readme", "github.com", "web"],
89 + ["https://github.com/acme/web.git.git", "github.com", "web.git"],
90 + ["https://github.com/acme/web.git.git/", "github.com", "web.git"],
91 + ["acme/web.git/", "github.com", "web"],
92 + ["ghe.example.com/acme/web.git/", "ghe.example.com", "web"],
93 + ] as const) {
94 + assert.deepStrictEqual(parseGitHubRepositorySelector(selector, "github.com"), {
95 + host,
96 + owner: "acme",
97 + name,
98 + });
99 + }
100 + });
101 +});
102 +
103 describe("gitHubApiHostForRemote", () => {
104 it("reads an SSH alias through github.com and a real host as itself", () => {
105 assert.strictEqual(gitHubApiHostForRemote("git@github:acme/web.git"), "github.com");
packages/source-control-github/src/server/gitHubRepositoryResolution.ts
+5 -3
@@ -101,11 +101,13 @@ export function parseGitHubRepositorySelector(
101 selector: string,
102 defaultHost: string,
103 ): GitHubRepositoryLocator | null {
104 - const trimmed = selector.trim().replace(/\.git$/i, "");
104 + // Like gh, a clone URL's `.git` comes off the path, before any trailing slash, query or fragment.
105 + const withoutGitSuffix = (path: string) => path.replace(/\.git\/*$/i, "");
106 + const trimmed = selector.trim();
107 if (/^https?:\/\//i.test(trimmed)) {
108 try {
109 const url = new URL(trimmed);
108 - const [owner, name, ...rest] = url.pathname.split("/").filter(Boolean);
110 + const [owner, name, ...rest] = withoutGitSuffix(url.pathname).split("/").filter(Boolean);
111 return owner && name && rest.length === 0
112 ? { host: url.host.toLowerCase(), owner, name }
113 : null;
@@ -113,7 +115,7 @@ export function parseGitHubRepositorySelector(
115 return null;
116 }
117 }
116 - const parts = trimmed.split("/").filter(Boolean);
118 + const parts = withoutGitSuffix(trimmed).split("/").filter(Boolean);
119 if (parts.length === 2) return { host: defaultHost, owner: parts[0]!, name: parts[1]! };
120 const host = parts[0]?.toLowerCase();
121 if (parts.length === 3 && host !== undefined && isGitHubHost(host))