From 7389d9e2cb2d61e6d60b01cc9e25348f7d827552 Mon Sep 17 00:00:00 2001 From: Asher Date: Mon, 12 Aug 2019 10:23:08 -0500 Subject: [PATCH] Use current URL for webview --- README.md | 4 ++-- scripts/vscode.patch | 12 ++++++++++-- src/server.ts | 4 +--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b4f031454..e660d8858 100644 --- a/README.md +++ b/README.md @@ -111,8 +111,8 @@ Our changes include: - Add a `code-server` schema. - Allow multiple extension directories (both user and built-in). - Rewrite assets requested by the browser to use the base URL. -- Modify the loader to use the base URL. -- Modify the web socket to use the base URL and TLS if necessary. +- Modify the loader, websocket, webview, and service worker to use the URL of + the page as a base (and TLS if necessary for the websocket). - Send client-side telemetry through the server. - Add a file prefix to ignore for temporary files created during upload. - Insert our upload service for use in editor windows and explorer. diff --git a/scripts/vscode.patch b/scripts/vscode.patch index a994b16ea..0f2a4ba7c 100644 --- a/scripts/vscode.patch +++ b/scripts/vscode.patch @@ -174,10 +174,10 @@ index 5b06636edb..60b508079a 100644 diff --git a/src/vs/code/browser/workbench/workbench.js b/src/vs/code/browser/workbench/workbench.js -index 65fae7c82d..c9744007c9 100644 +index 65fae7c82d..9a9b8bbe3b 100644 --- a/src/vs/code/browser/workbench/workbench.js +++ b/src/vs/code/browser/workbench/workbench.js -@@ -7,15 +7,20 @@ +@@ -7,21 +7,26 @@ (function () { @@ -205,6 +205,14 @@ index 65fae7c82d..c9744007c9 100644 } }); + require(['vs/workbench/workbench.web.api'], function (api) { + const options = JSON.parse(document.getElementById('vscode-workbench-web-configuration').getAttribute('data-settings')); +- ++ options.webviewEndpoint = `${base}/webview/`; + api.create(document.body, options); + }); + })(); +\ No newline at end of file diff --git a/src/vs/platform/environment/common/environment.ts b/src/vs/platform/environment/common/environment.ts index a6c9eb9d11..3f8995b727 100644 --- a/src/vs/platform/environment/common/environment.ts diff --git a/src/server.ts b/src/server.ts index fc8cc1c4b..0c0b9e24f 100644 --- a/src/server.ts +++ b/src/server.ts @@ -469,7 +469,6 @@ export class MainServer extends Server { const workspacePath = parsedUrl.query.workspace as string | undefined; const folderPath = !workspacePath ? parsedUrl.query.folder as string | undefined || this.options.folderUri || cwd: undefined; const remoteAuthority = request.headers.host as string; - const webviewEndpoint = this.withBase(request, "/webview/"); const transformer = getUriTransformer(remoteAuthority); const options: Options = { WORKBENCH_WEB_CONGIGURATION: { @@ -480,7 +479,6 @@ export class MainServer extends Server { ? transformer.transformOutgoing(URI.file(sanitizeFilePath(folderPath, cwd))) : undefined, remoteAuthority, - webviewEndpoint, }, REMOTE_USER_DATA_URI: transformer.transformOutgoing( (this.services.get(IEnvironmentService) as EnvironmentService).webUserDataHome, @@ -497,7 +495,7 @@ export class MainServer extends Server { for (const key in options) { content = content.replace(`"{{${key}}}"`, `'${JSON.stringify(options[key as keyof Options])}'`); } - content = content.replace('{{WEBVIEW_ENDPOINT}}', webviewEndpoint); + content = content.replace("{{WEBVIEW_ENDPOINT}}", ""); return { content, filePath }; }