Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(shared): recognize SSH remotes with a single path component #31781

Mergeddarshmahadevia(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/31781/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 3 additions and 1 deletion.

x
0 of 2 viewed, 2 left
2 additions and 0 deletionspackages/shared/src/sourceControl.test.tsModified
View file
@@ -8,6 +8,7 @@
"ssh://git@github.com/owner/repo.git",
"github.com:owner/repo.git",
"github-work:owner/repo.git",
+ "gitserver:repo.git",
])("reads %s as SSH", (remoteUrl) => {
expect(isSshRemoteUrl(remoteUrl)).toBe(true);
});
@@ -19,6 +20,7 @@
"./team:group/repo",
"file:///srv/git/repo.git",
"hg::owner/repo",
+ "C:repo.git",
])("does not read %s as SSH", (remoteUrl) => {
expect(isSshRemoteUrl(remoteUrl)).toBe(false);
});
1 addition and 1 deletionpackages/shared/src/sourceControl.tsModified
View file
@@ -1,7 +1,7 @@
const SCP_SSH_REMOTE_PATTERN = /^[a-zA-Z0-9._-]+@([^:/]+):/;
// Git reads `host:path` as SSH too, leaving the user to ssh config. A single letter is a Windows
// drive and `::` names a remote helper.
-const USERLESS_SCP_SSH_REMOTE_PATTERN = /^([^@:/\\\s]{2,}):(?!:)\/?[^/\s]+(?:\/[^/\s]+)+\/?$/u;
+const USERLESS_SCP_SSH_REMOTE_PATTERN = /^([^@:/\\\s]{2,}):(?!:)\/?[^/\s]+(?:\/[^/\s]+)*\/?$/u;
​
/** Null unless the remote is `host:path`, with no user. */
export function userlessScpRemoteHost(remoteUrl: string): string | null {