mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-29 13:03:42 +01:00
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:
@@ -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+?:/, '');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user