# Files changed · PR \#23848 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/23848/diffs)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

[fix\(gitlab\): accept merge request URLs from self-hosted hosts](https://git.cafe/pingdotgg/t3code/pull/23848.md)

Version: 7

Head commit: c52430b51673d79baf739fa3bddc787934192632

Base commit: d53873b6a4799e87afd63c8d288ef0089f5a3748

Comparison base: d53873b6a4799e87afd63c8d288ef0089f5a3748

Showing up to 20 entries from this revision. If the pull request changes, reopen the first page before continuing.

## packages/client-runtime/src/pullRequestLinkInput.test.ts

Status: modified; +7; −0

```diff
@@ -134,6 +134,13 @@
     ).toBe("https://acme.visualstudio.com/project/_git/t3code/pullrequest/42");
   });
 
+  it.each([
+    "https://code.example.com/group/project/-/merge_requests/42",
+    "http://git.internal/group/sub/project/-/merge_requests/7",
+  ])("accepts self-hosted GitLab merge request URL %s", (url) => {
+    expect(parsePullRequestReference(url)).toBe(url);
+  });
+
   it("accepts gh pr checkout commands with raw numbers", () => {
     expect(parsePullRequestReference("gh pr checkout 42")).toBe("42");
   });
```

## packages/source-control-gitlab/src/shared/definition.test.ts

Status: modified; +22; −0

```diff
@@ -31,6 +31,28 @@
     expect(parse("https://gitlab.com/t3code/-/merge_requests/12")).toBeNull();
   });
 
+  it("recognizes only merge request URLs it can parse", () => {
+    for (const url of [
+      "https://gitlab.com/g/p?x=/-/merge_requests/5",
+      "https://gitlab.com/g/p#/-/merge_requests/5",
+      "https://gitlab.com?x=/g/p/-/merge_requests/5",
+      "https://gitlab.com#/g/p/-/merge_requests/5",
+      "https://gitlab.com/t3code/-/merge_requests/12",
+      "https://gitlab.com/g//-/merge_requests/5",
+    ]) {
+      expect(definition.isChangeRequestReference(url), url).toBe(false);
+      expect(parse(url), url).toBeNull();
+    }
+    for (const url of [
+      "https://code.acme.test/a/b/c/-/merge_requests/7?tab=diffs",
+      "http://git.internal/a/b/c/-/merge_requests/7#note_1",
+      "https://code.acme.test/a/b/c/-/merge_requests/7/diffs",
+    ]) {
+      expect(definition.isChangeRequestReference(url), url).toBe(true);
+      expect(parse(url), url).toMatchObject({ repository: "a/b/c", number: 7 });
+    }
+  });
+
   it("builds merge request URLs below the repository", () => {
     expect(
       definition.changeRequestUrl({
```

## packages/source-control-gitlab/src/shared/definition.ts

Status: modified; +1; −1

```diff
@@ -11,7 +11,7 @@
 
 const CHECKOUT_COMMAND = /^glab\s+mr\s+checkout\s+(.+)$/i;
 const CHANGE_REQUEST_REFERENCE =
-  /^https:\/\/[^/\s]*gitlab[^/\s]*\/.+\/-\/merge_requests\/(\d+)(?:[/?#].*)?$/i;
+  /^https?:\/\/[^/?#\s]+\/[^/?#\s]+(?:\/[^/?#\s]+)+\/-\/merge_requests\/(\d+)(?:[/?#].*)?$/i;
 
 // Self-managed GitLab runs on any hostname and nests projects in groups.
 const CHANGE_REQUEST_PATH = /^\/([^/]+(?:\/[^/]+)+)\/-\/merge_requests\/(\d+)(?:\/|$)/u;
```
