Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(shared): match source-control providers by DNS label #6175

Mergedgb1095(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/6175/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 36 additions and 3 deletions.

x
0 of 2 viewed, 2 left
29 additions and 0 deletionspackages/shared/src/sourceControl.test.tsModified
View file
@@ -75,4 +75,33 @@
baseUrl: "https://self-hosted.example.test:8443",
});
});
+​
+ it("matches self-hosted providers by complete DNS labels", () => {
+ expect(
+ detectSourceControlProviderFromRemoteUrl("https://github.example.com/owner/repo.git")?.kind,
+ ).toBe("github");
+ expect(
+ detectSourceControlProviderFromRemoteUrl("https://gitlab.example.com/group/repo.git")?.kind,
+ ).toBe("gitlab");
+ expect(
+ detectSourceControlProviderFromRemoteUrl("https://bitbucket.example.com/workspace/repo.git")
+ ?.kind,
+ ).toBe("bitbucket");
+ });
+​
+ it("does not match provider names embedded in unrelated DNS labels", () => {
+ expect(
+ detectSourceControlProviderFromRemoteUrl("https://notgithub.example.com/owner/repo.git")
+ ?.kind,
+ ).toBe("unknown");
+ expect(
+ detectSourceControlProviderFromRemoteUrl("https://notgitlab.example.com/group/repo.git")
+ ?.kind,
+ ).toBe("unknown");
+ expect(
+ detectSourceControlProviderFromRemoteUrl(
+ "https://notbitbucket.example.com/workspace/repo.git",