Fix image preview extension for remote

Fixes #81434

- Make image preview a ui exension

- Add logic so that `asWebviewUri` supports preserving the scheme of the requested resource. This is important as we know where to load the resource from
This commit is contained in:
Matt Bierner
2019-09-25 16:24:10 -07:00
parent a2ed64badb
commit 6b947b14ed
8 changed files with 37 additions and 17 deletions

View File

@@ -17,7 +17,13 @@ export function asWebviewUri(
resource: vscode.Uri,
): vscode.Uri {
const uri = initData.webviewResourceRoot
.replace('{{resource}}', resource.toString().replace(/^\S+?:/, ''))
// Make sure we preserve the scheme of the resource but convert it into a normal path segment
// The scheme is important as we need to know if we are requesting a local or a remote resource.
.replace('{{resource}}', resource.scheme + withoutScheme(resource))
.replace('{{uuid}}', uuid);
return URI.parse(uri);
}
function withoutScheme(resource: vscode.Uri): string {
return resource.toString().replace(/^\S+?:/, '');
}