From ab34989743d730e11150e454027af5b169dfa1c0 Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Wed, 25 May 2022 15:31:30 +0200 Subject: [PATCH 1/2] Add support for SSH Uri --- extensions/git/src/protocolHandler.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/extensions/git/src/protocolHandler.ts b/extensions/git/src/protocolHandler.ts index c0c3f2a652734..36313b9b96ca1 100644 --- a/extensions/git/src/protocolHandler.ts +++ b/extensions/git/src/protocolHandler.ts @@ -38,7 +38,18 @@ export class GitProtocolHandler implements UriHandler { let cloneUri: Uri; try { - cloneUri = Uri.parse(Array.isArray(data.url) ? data.url[0] : data.url, true); + let rawUri = Array.isArray(data.url) ? data.url[0] : data.url; + + // Handle SSH Uri + // Ex: git@github.com:microsoft/vscode.git + if (/^git@[^\/:]+:/i.test(rawUri)) { + rawUri = rawUri.replace(/:/, '/'); + rawUri = `ssh://${rawUri}`; + } + + cloneUri = Uri.parse(rawUri, true); + + // Validate against supported schemes if (!schemes.has(cloneUri.scheme.toLowerCase())) { throw new Error('Unsupported scheme.'); } From 63205739a315a33e8227dcb570e84e0c5e39ce97 Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Tue, 14 Jun 2022 16:17:01 +0200 Subject: [PATCH 2/2] Update extensions/git/src/protocolHandler.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: João Moreno --- extensions/git/src/protocolHandler.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/extensions/git/src/protocolHandler.ts b/extensions/git/src/protocolHandler.ts index 36313b9b96ca1..33decfe18469d 100644 --- a/extensions/git/src/protocolHandler.ts +++ b/extensions/git/src/protocolHandler.ts @@ -42,10 +42,7 @@ export class GitProtocolHandler implements UriHandler { // Handle SSH Uri // Ex: git@github.com:microsoft/vscode.git - if (/^git@[^\/:]+:/i.test(rawUri)) { - rawUri = rawUri.replace(/:/, '/'); - rawUri = `ssh://${rawUri}`; - } + rawUri = rawUri.replace(/^(git@[^\/:]+)(:)/i, 'ssh://$1/'); cloneUri = Uri.parse(rawUri, true);