Skip to content

Commit aeb4485

Browse files
AlexTugarevroboquat
authored andcommitted
[server] properly parse ports of clone URLs
Otherwise this breaks the lookup of services mapped by host (including the port.) This is the quite apparent aftermath of enabling ports in SCM locations.
1 parent 8b94c54 commit aeb4485

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

components/server/src/repohost/repo-url.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ export class RepoUrlTest {
7272
repo: "yolo",
7373
});
7474
}
75+
76+
@test public parseScmCloneUrl_with_port() {
77+
const testUrl = RepoURL.parseRepoUrl("https://foo.bar.com:12345/scm/proj/repoName.git");
78+
expect(testUrl).to.deep.include({
79+
host: "foo.bar.com:12345",
80+
repoKind: "projects",
81+
owner: "proj",
82+
repo: "repoName",
83+
});
84+
}
7585
}
7686

7787
module.exports = new RepoUrlTest();

components/server/src/repohost/repo-url.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export namespace RepoURL {
1010
repoUrl: string,
1111
): { host: string; owner: string; repo: string; repoKind?: string } | undefined {
1212
const u = new URL(repoUrl);
13-
const host = u.hostname || "";
13+
const host = u.host || "";
1414
const path = u.pathname || "";
1515
const segments = path.split("/").filter((s) => !!s); // e.g. [ 'gitpod-io', 'gitpod.git' ]
1616
if (segments.length === 2) {

0 commit comments

Comments
 (0)