Skip to content

Commit

Permalink
Git - add support for SSH Uri (#152051)
Browse files Browse the repository at this point in the history
* Add support for SSH Uri

* Update extensions/git/src/protocolHandler.ts

Co-authored-by: João Moreno <[email protected]>

Co-authored-by: João Moreno <[email protected]>
  • Loading branch information
lszomoru and joaomoreno authored Jun 14, 2022
1 parent ef8f1ff commit c531865
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion extensions/git/src/protocolHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@ 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: [email protected]:microsoft/vscode.git
rawUri = rawUri.replace(/^(git@[^\/:]+)(:)/i, 'ssh://$1/');

cloneUri = Uri.parse(rawUri, true);

// Validate against supported schemes
if (!schemes.has(cloneUri.scheme.toLowerCase())) {
throw new Error('Unsupported scheme.');
}
Expand Down

0 comments on commit c531865

Please sign in to comment.