Use current URL for webview

This commit is contained in:
Asher 2019-08-12 10:23:08 -05:00
parent 1d61cbe536
commit 7389d9e2cb
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
3 changed files with 13 additions and 7 deletions

View File

@ -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.

View File

@ -174,10 +174,10 @@ index 5b06636edb..60b508079a 100644
<!-- Require our AMD loader -->
<script src="./out/vs/loader.js"></script>
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

View File

@ -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 };
}