Skip to content

Commit be7d20e

Browse files
committed
fix(source-control): accept Forgejo links on custom hostnames
1 parent 24d2423 commit be7d20e

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎packages/shared/src/changeRequestUrl.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ describe("parseChangeRequestUrl", () => {
2424
});
2525
});
2626

27+
it("reads Forgejo URLs even when the hostname contains github", () => {
28+
expect(parseChangeRequestUrl("https://github.internal/team/repo/pulls/7")).toEqual({
29+
host: "github.internal",
30+
authority: "github.internal",
31+
repository: "team/repo",
32+
number: 7,
33+
});
34+
});
35+
2736
it("reads a supported GitHub host with a middle DNS label", () => {
2837
expect(parseChangeRequestUrl("https://code.github.example.com/acme/web/pull/42")).toEqual({
2938
host: "code.github.example.com",

‎packages/shared/src/changeRequestUrl.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function parseChangeRequestUrl(targetUrl: string): ChangeRequestLink | nu
5151
// GitHub, and any Enterprise install: /{owner}/{repo}/pull/{n}
5252
if (isHostOf(host, "github.com", "github")) {
5353
const match = /^\/([^/]+\/[^/]+)\/pull\/(\d+)(?:\/|$)/u.exec(url.pathname);
54-
return claim(host, match);
54+
if (match) return claim(host, match);
5555
}
5656
// Forgejo and Gitea use /pulls/ on arbitrary self-hosted domains.
5757
const forgejo = /^\/([^/]+(?:\/[^/]+)+)\/pulls\/(\d+)(?:\/|$)/u.exec(url.pathname);

0 commit comments

Comments
 (0)