From f6449af5f11bd3e30eeca2c8226c1a5779b2ad69 Mon Sep 17 00:00:00 2001 From: Anton Kosyakov Date: Thu, 14 May 2020 19:59:59 +0000 Subject: [PATCH] [electron] fix resolution of hostname placeholder Signed-off-by: Anton Kosyakov --- .vscode/launch.json | 5 +++-- packages/core/src/browser/endpoint.ts | 2 +- .../src/main/browser/webview/webview-environment.ts | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 5a5a5af3b346e..3a88680b430c3 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -33,7 +33,8 @@ "--no-cluster", "--app-project-path=${workspaceRoot}/examples/electron", "--remote-debugging-port=9222", - "--no-app-auto-install" + "--no-app-auto-install", + "--plugins=local-dir:../../plugins" ], "env": { "NODE_ENV": "development", @@ -189,4 +190,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/packages/core/src/browser/endpoint.ts b/packages/core/src/browser/endpoint.ts index 8d2f95da51aef..21f3ee124a561 100644 --- a/packages/core/src/browser/endpoint.ts +++ b/packages/core/src/browser/endpoint.ts @@ -52,7 +52,7 @@ export class Endpoint { return this.location.pathname; } - protected get host(): string { + get host(): string { if (this.options.host) { return this.options.host; } diff --git a/packages/plugin-ext/src/main/browser/webview/webview-environment.ts b/packages/plugin-ext/src/main/browser/webview/webview-environment.ts index 520134bdf5f48..018dddec3c8d7 100644 --- a/packages/plugin-ext/src/main/browser/webview/webview-environment.ts +++ b/packages/plugin-ext/src/main/browser/webview/webview-environment.ts @@ -34,7 +34,8 @@ export class WebviewEnvironment { try { const variable = await this.environments.getValue(WebviewExternalEndpoint.pattern); const value = variable && variable.value || WebviewExternalEndpoint.defaultPattern; - this.externalEndpointHost.resolve(value.replace('{{hostname}}', window.location.host || 'localhost')); + const { host } = new Endpoint(); + this.externalEndpointHost.resolve(value.replace('{{hostname}}', host)); } catch (e) { this.externalEndpointHost.reject(e); }