Skip to content

Commit 30d716e

Browse files
committed
fix(shared): key one-segment SSH repository paths
1 parent e0fcab3 commit 30d716e

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎packages/shared/src/git.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ describe("normalizeGitRemoteUrl", () => {
9999
"192.0.2.10/srv/git/app",
100100
);
101101
expect(normalizeGitRemoteUrl("file:///srv/git/App.git")).toBe("file:///srv/git/app");
102+
// A repository straight under the root has one path segment.
103+
expect(normalizeGitRemoteUrl("[email protected]:/App.git")).toBe("192.0.2.10/app");
104+
expect(normalizeGitRemoteUrl("ssh://[email protected]/App.git")).toBe("192.0.2.10/app");
102105
});
103106

104107
it("leaves a Windows drive path alone", () => {

‎packages/shared/src/git.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export function normalizeGitRemoteUrl(value: string): string {
160160
try {
161161
const url = new URL(normalized);
162162
const repositorySegments = url.pathname.split("/").filter((segment) => segment.length > 0);
163-
if (url.hostname && repositorySegments.length > 1) {
163+
if (url.hostname && repositorySegments.length > 0) {
164164
return (
165165
azureDevOpsRepositoryKey(url.hostname, repositorySegments) ??
166166
`${url.hostname}/${repositorySegments.join("/")}`
@@ -176,7 +176,7 @@ export function normalizeGitRemoteUrl(value: string): string {
176176
// path (`host:/srv/repo`) keys like `ssh://host/srv/repo`, the same repository.
177177
const scpStyleHostAndPath = normalized.includes("://")
178178
? null
179-
: /^(?:[a-zA-Z0-9._-]+@)?([^:/\s@]{2,}):\/?([^/\s]+(?:\/[^/\s]+)+)$/i.exec(normalized);
179+
: /^(?:[a-zA-Z0-9._-]+@)?([^:/\s@]{2,}):\/?([^/\s]+(?:\/[^/\s]+)*)$/i.exec(normalized);
180180
const scpHost = scpStyleHostAndPath?.[1];
181181
const scpPath = scpStyleHostAndPath?.[2];
182182
if (scpHost && scpPath) {

0 commit comments

Comments
 (0)