diff --git a/src/features/github/data/data.test.ts b/src/features/github/data/data.test.ts index 703de25e2..97efc9f6a 100644 --- a/src/features/github/data/data.test.ts +++ b/src/features/github/data/data.test.ts @@ -401,6 +401,9 @@ describe("pull request helpers", () => { "ssh://git@github.com/o/r.git", "ssh://git@github.com:22/o/r.git", "git://github.com/o/r", + // GitHub's SSH-over-HTTPS host. + "ssh://git@ssh.github.com:443/o/r.git", + "git@ssh.github.com:o/r.git", ]) expect(parseGitHubRemote(url), url).toEqual({ owner: "o", name: "r" }); expect(parseGitHubRemote("https://gitlab.com/o/r.git")).toBeNull(); diff --git a/src/features/github/data/model.ts b/src/features/github/data/model.ts index 492ea2933..66aae9de9 100644 --- a/src/features/github/data/model.ts +++ b/src/features/github/data/model.ts @@ -413,10 +413,10 @@ export function repositoryDisplayName( return showOwner ? `${repo.owner}/${repo.name}` : repo.name; } -/** `owner/name` of a github.com remote URL (https, ssh or scp-like), else null. */ +/** `owner/name` of a github.com remote URL (https, ssh or scp-like; SSH also via ssh.github.com), else null. */ export function parseGitHubRemote(url: string): GHRepositoryCoordinates | null { const m = - /^(?:https?:\/\/(?:[^@/]+@)?|ssh:\/\/(?:[^@/]+@)?|git:\/\/|(?:[^@/]+@)?)(?:www\.)?github\.com(?::\d+(?=\/))?[:/]+([^/]+)\/([^/]+?)(?:\.git)?\/?$/i.exec( + /^(?:(?:https?:\/\/(?:[^@/]+@)?|git:\/\/)(?:www\.)?|(?:ssh:\/\/(?:[^@/]+@)?|(?:[^@/]+@)?)(?:www\.|ssh\.)?)github\.com(?::\d+(?=\/))?[:/]+([^/]+)\/([^/]+?)(?:\.git)?\/?$/i.exec( url.trim(), ); return m ? { owner: m[1]!, name: m[2]! } : null;