Strip protocol from remote authority

In Google cloud shell the host header is 127.0.0.1:8080 instead of the
actual URL. This is what we write out to the HTML so VS Code can pick it
up. However cloud shell rewrites this string when found in the HTML
before serving it so it becomes https://8080-[...].appspot.com,
resulting in an extra unexpected https:// in the
URI (vscode-remote://https://8080[...]). The resulting malformed URI
causes the extension host to exit.

- Fixes #1471
- Fixes #1468
- Fixes #1440 (most likely).
This commit is contained in:
Asher 2020-04-01 13:41:05 -05:00
parent a4c0fd1fdc
commit 26584f2060
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
1 changed files with 21 additions and 2 deletions

View File

@ -248,7 +248,7 @@ index 2c64061da7..c0ef8faedd 100644
// Do nothing. If we can't read the file we have no
// language pack config.
diff --git a/src/vs/code/browser/workbench/workbench.ts b/src/vs/code/browser/workbench/workbench.ts
index 45f6f17ce0..79fde0b92c 100644
index 45f6f17ce0..4d1a590a7c 100644
--- a/src/vs/code/browser/workbench/workbench.ts
+++ b/src/vs/code/browser/workbench/workbench.ts
@@ -246,12 +246,18 @@ class WorkspaceProvider implements IWorkspaceProvider {
@ -272,7 +272,26 @@ index 45f6f17ce0..79fde0b92c 100644
}
// Append payload if any
@@ -302,35 +308,6 @@ class WorkspaceProvider implements IWorkspaceProvider {
@@ -290,6 +296,18 @@ class WorkspaceProvider implements IWorkspaceProvider {
const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents, workspaceUri?: UriComponents } = JSON.parse(configElementAttribute);
+ // Strip the protocol from the authority if it exists.
+ const normalizeAuthority = (authority: string): string => authority.replace(/^https?:\/\//, "");
+ if (config.remoteAuthority) {
+ (config as any).remoteAuthority = normalizeAuthority(config.remoteAuthority);
+ }
+ if (config.workspaceUri) {
+ config.workspaceUri.authority = normalizeAuthority(config.workspaceUri.authority);
+ }
+ if (config.folderUri) {
+ config.folderUri.authority = normalizeAuthority(config.folderUri.authority);
+ }
+
// Revive static extension locations
if (Array.isArray(config.staticExtensions)) {
config.staticExtensions.forEach(extension => {
@@ -302,35 +320,6 @@ class WorkspaceProvider implements IWorkspaceProvider {
let workspace: IWorkspace;
let payload = Object.create(null);