From 26584f2060ab135a374fc2079265f625f13ab431 Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 1 Apr 2020 13:41:05 -0500 Subject: [PATCH] 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). --- ci/vscode.patch | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/ci/vscode.patch b/ci/vscode.patch index bfc3fdd37..7661bedd6 100644 --- a/ci/vscode.patch +++ b/ci/vscode.patch @@ -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);