Skip to content

Commit

Permalink
Fix webview special paths for resources and re-enable test
Browse files Browse the repository at this point in the history
Fixes #103419
  • Loading branch information
mjbvz committed Jul 28, 2020
1 parent 9d72fcb commit 7493065
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions extensions/vscode-api-tests/src/singlefolder-tests/webview.test.ts
Expand Up @@ -272,12 +272,18 @@ suite('vscode API - webview', () => {
const response = await sendRecieveMessage(webview, { src: imagePath.toString() });
assert.strictEqual(response.value, true);
}
// {
// // #102188. Resource filename containing special characters like '%', '#', '?'.
// const imagePath = webview.webview.asWebviewUri(workspaceFile('image%02.png'));
// const response = await sendRecieveMessage(webview, { src: imagePath.toString() });
// assert.strictEqual(response.value, true);
// }
{
// #102188. Resource filename containing special characters like '%', '#', '?'.
const imagePath = webview.webview.asWebviewUri(workspaceFile('image%02.png'));
const response = await sendRecieveMessage(webview, { src: imagePath.toString() });
assert.strictEqual(response.value, true);
}
{
// #102188. Resource filename containing special characters like '%', '#', '?'.
const imagePath = webview.webview.asWebviewUri(workspaceFile('image%.png'));
const response = await sendRecieveMessage(webview, { src: imagePath.toString() });
assert.strictEqual(response.value, true);
}
{
const imagePath = webview.webview.asWebviewUri(workspaceFile('no-such-image.png'));
const response = await sendRecieveMessage(webview, { src: imagePath.toString() });
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/webview/browser/webviewElement.ts
Expand Up @@ -154,7 +154,7 @@ export class IFrameWebview extends BaseWebview<HTMLIFrameElement> implements Web
authority: extensionLocation.authority,
path: '/vscode-resource',
query: JSON.stringify({
requestResourcePath: uri.path
requestResourcePath: encodeURIComponent(uri.path).replace(/%2F/g, '/').replace(/%25/g, '%')
})
});
}
Expand Down

0 comments on commit 7493065

Please sign in to comment.