@@ -326,7 +326,8 @@ export class GitUri extends ((Uri as any) as UriEx) {
326326 static git ( fileName : string , repoPath ?: string ) {
327327 const path = GitUri . resolve ( fileName , repoPath ) ;
328328 return Uri . parse (
329- `git:${ encodeURIComponent ( path ) } ?${ encodeURIComponent (
329+ // Change encoded / back to / otherwise uri parsing won't work properly
330+ `git:${ encodeURIComponent ( path ) . replace ( / % 2 F / g, '/' ) } ?${ encodeURIComponent (
330331 JSON . stringify ( {
331332 // Ensure we use the fsPath here, otherwise the url won't open properly
332333 path : Uri . file ( path ) . fsPath ,
@@ -389,19 +390,18 @@ export class GitUri extends ((Uri as any) as UriEx) {
389390 shortSha = uriOrRef . shortSha ;
390391 }
391392
392- repoPath = Strings . normalizePath ( repoPath ! ) ;
393- const repoName = paths . basename ( repoPath ) ;
394-
395393 const filePath = Strings . normalizePath ( fileName , { addLeadingSlash : true } ) ;
396394 const data : IUriRevisionData = {
397395 path : filePath ,
398396 ref : ref ,
399- repoPath : repoPath
397+ repoPath : Strings . normalizePath ( repoPath ! )
400398 } ;
401399
402400 const uri = Uri . parse (
403- `${ DocumentSchemes . GitLens } :///${ encodeURIComponent ( repoName ) } @${ shortSha } ${
404- filePath === slash ? empty : encodeURIComponent ( filePath )
401+ // Replace / in the authority with a similar unicode characters otherwise parsing will be wrong
402+ `${ DocumentSchemes . GitLens } ://${ encodeURIComponent ( shortSha ! . replace ( / \/ / g, '\u200A\u2215\u200A' ) ) } ${
403+ // Change encoded / back to / otherwise uri parsing won't work properly
404+ filePath === slash ? empty : encodeURIComponent ( filePath ) . replace ( / % 2 F / g, '/' )
405405 } ?${ encodeURIComponent ( JSON . stringify ( data ) ) } `
406406 ) ;
407407 return uri ;
0 commit comments