Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(shared): preserve IPv6 hosts when switching clone protocols #30798

MergedLucenx9(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/30798/headmerged by maria-rcks View on GitHub

Showing 2 changed files with 26 additions and 3 deletions.

x
0 of 2 viewed, 2 left
23 additions and 0 deletionspackages/shared/src/cloneUrl.test.tsModified
View file
@@ -117,6 +117,18 @@
expect(cloneUrlForProtocol("ssh://git@gitlab.com/group/sub/repo.git", "https")).toBe(
"https://gitlab.com/group/sub/repo.git",
+ expect(cloneUrlForProtocol("git@[2001:db8::1]:org/repo.git", "https")).toBe(
+ "https://[2001:db8::1]/org/repo.git",
+ );
+ expect(cloneUrlForProtocol("[2001:db8::1]:org/repo.git", "https")).toBe(
+ "https://[2001:db8::1]/org/repo.git",
+ );
+ expect(cloneUrlForProtocol("ssh://git@[2001:db8::1]/org/repo.git", "https")).toBe(
+ "https://[2001:db8::1]/org/repo.git",
+ );
+ expect(cloneUrlForProtocol("https://[2001:db8::1]/org/repo.git", "ssh")).toBe(
+ "git@[2001:db8::1]:org/repo.git",
+ );
});
​
it("keeps the URL as is for its own protocol and drops HTTPS credentials on switch", () => {
@@ -134,6 +146,17 @@
expect(cloneUrlForProtocol("https://host.example:8443/a/b.git", "https")).toBe(
"https://host.example:8443/a/b.git",
+ expect(cloneUrlForProtocol("ssh://git@[2001:db8::1]:2222/a/b.git", "https")).toBeNull();
+ expect(cloneUrlForProtocol("ssh://git@[2001:db8::1]:2222/a/b.git", "ssh")).toBe(
+ "ssh://git@[2001:db8::1]:2222/a/b.git",
+ );
+ expect(cloneUrlForProtocol("https://[2001:db8::1]:8443/a/b.git", "ssh")).toBeNull();
+ expect(cloneUrlForProtocol("https://[2001:db8::1]:8443/a/b.git", "https")).toBe(