Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(shared): clone URL rewrite survives passwords that contain @ #27845

Closedsamkelly880(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/27845/headopened View on GitHub

Showing 2 changed files with 11 additions and 1 deletion.

x
0 of 2 viewed, 2 left
10 additions and 0 deletionspackages/shared/src/cloneUrl.test.tsModified
View file
@@ -13,6 +13,11 @@
expect(cloneUrlForProtocol("ssh://git@gitlab.com/group/sub/repo.git", "https")).toBe(
"https://gitlab.com/group/sub/repo.git",
);
+ expect(cloneUrlForProtocol("https://host/é/repo.git", "ssh")).toBe("git@host:é/repo.git");
+ expect(cloneUrlForProtocol("https://host//srv/git/repo.git", "ssh")).toBe(
+ "git@host:/srv/git/repo.git",
+ );
+ expect(cloneUrlForProtocol("http:team/repo.git", "https")).toBe("https://http/team/repo.git");
});
​
it("keeps the URL as is for its own protocol and drops HTTPS credentials on switch", () => {
@@ -22,11 +27,16 @@
expect(cloneUrlForProtocol("https://token@github.com/a/b.git", "ssh")).toBe(
"git@github.com:a/b.git",
);
+ expect(cloneUrlForProtocol("https://user:tok@en@github.com/a/b.git", "ssh")).toBe(
+ "git@github.com:a/b.git",
+ );
});
​
it("refuses rewrites that would guess wrong", () => {
expect(cloneUrlForProtocol("ssh://git@host.example:2222/a/b.git", "https")).toBeNull();
expect(cloneUrlForProtocol("https://host.example:8443/a/b.git", "ssh")).toBeNull();
+ expect(cloneUrlForProtocol("https://host.example:443/a/b.git", "ssh")).toBeNull();
+ expect(cloneUrlForProtocol("http://host.example:80/a/b.git", "ssh")).toBeNull();
expect(cloneUrlForProtocol("https://host.example:8443/a/b.git", "https")).toBe(
"https://host.example:8443/a/b.git",
);