Add base path to update endpoint from VS Code
This will make it work regardless of what the current URL happens to be. Also move the telemetry setting into the options since we might as well make use of it seeing as how we have to parse it for the base path anyway.
This commit is contained in:
@ -20,10 +20,8 @@
|
||||
|
||||
<!-- Workarounds/Hacks (remote user data uri) -->
|
||||
<meta id="vscode-remote-user-data-uri" data-settings="{{REMOTE_USER_DATA_URI}}" />
|
||||
<meta id="vscode-remote-commit" data-settings="{{COMMIT}}" />
|
||||
<meta id="vscode-remote-product-configuration" data-settings="{{PRODUCT_CONFIGURATION}}" />
|
||||
<meta id="vscode-remote-nls-configuration" data-settings="{{NLS_CONFIGURATION}}" />
|
||||
<meta id="vscode-disable-telemetry" data-value="{{DISABLE_TELEMETRY}}" />
|
||||
|
||||
<!-- Workbench Icon/Manifest/CSS -->
|
||||
<link rel="icon" href="{{BASE}}/static/{{COMMIT}}/src/browser/media/favicon.ico" type="image/x-icon" />
|
||||
@ -53,9 +51,7 @@
|
||||
const parts = window.location.pathname.replace(/^\//g, "").split("/")
|
||||
parts[parts.length - 1] = "{{BASE}}"
|
||||
const url = new URL(window.location.origin + "/" + parts.join("/"))
|
||||
const el = document.getElementById("vscode-remote-commit")
|
||||
const commit = el ? el.getAttribute("data-settings") : ""
|
||||
const staticBase = url.href.replace(/\/+$/, "") + "/static/" + commit + "/lib/vscode"
|
||||
const staticBase = url.href.replace(/\/+$/, "") + "/static/{{COMMIT}}/lib/vscode"
|
||||
let nlsConfig
|
||||
try {
|
||||
nlsConfig = JSON.parse(document.getElementById("vscode-remote-nls-configuration").getAttribute("data-settings"))
|
||||
|
@ -8,6 +8,7 @@ import * as path from "path"
|
||||
import * as url from "url"
|
||||
import {
|
||||
CodeServerMessage,
|
||||
Options,
|
||||
StartPath,
|
||||
VscodeMessage,
|
||||
VscodeOptions,
|
||||
@ -205,8 +206,11 @@ export class VscodeHttpProvider extends HttpProvider {
|
||||
.replace(`"{{PRODUCT_CONFIGURATION}}"`, `'${JSON.stringify(options.productConfiguration)}'`)
|
||||
.replace(`"{{WORKBENCH_WEB_CONFIGURATION}}"`, `'${JSON.stringify(options.workbenchWebConfiguration)}'`)
|
||||
.replace(`"{{NLS_CONFIGURATION}}"`, `'${JSON.stringify(options.nlsConfiguration)}'`)
|
||||
.replace("{{DISABLE_TELEMETRY}}", this.args["disable-telemetry"] ? "true" : "false")
|
||||
return this.replaceTemplates(route, response)
|
||||
return this.replaceTemplates<Options>(route, response, {
|
||||
base: this.base(route),
|
||||
commit: this.options.commit,
|
||||
disableTelemetry: !!this.args["disable-telemetry"],
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -185,22 +185,30 @@ export abstract class HttpProvider {
|
||||
/**
|
||||
* Replace common templates strings.
|
||||
*/
|
||||
protected replaceTemplates(route: Route, response: HttpStringFileResponse, sessionId?: string): HttpStringFileResponse
|
||||
protected replaceTemplates<T extends object>(
|
||||
route: Route,
|
||||
response: HttpStringFileResponse,
|
||||
options: T,
|
||||
): HttpStringFileResponse
|
||||
protected replaceTemplates(
|
||||
route: Route,
|
||||
response: HttpStringFileResponse,
|
||||
sessionId?: string,
|
||||
sessionIdOrOptions?: string | object,
|
||||
): HttpStringFileResponse {
|
||||
const options: Options = {
|
||||
base: this.base(route),
|
||||
commit: this.options.commit,
|
||||
logLevel: logger.level,
|
||||
sessionId,
|
||||
if (typeof sessionIdOrOptions === "undefined" || typeof sessionIdOrOptions === "string") {
|
||||
sessionIdOrOptions = {
|
||||
base: this.base(route),
|
||||
commit: this.options.commit,
|
||||
logLevel: logger.level,
|
||||
sessionID: sessionIdOrOptions,
|
||||
} as Options
|
||||
}
|
||||
response.content = response.content
|
||||
.replace(/{{COMMIT}}/g, this.options.commit)
|
||||
.replace(/{{TO}}/g, Array.isArray(route.query.to) ? route.query.to[0] : route.query.to || "/dashboard")
|
||||
.replace(/{{BASE}}/g, this.base(route))
|
||||
.replace(/"{{OPTIONS}}"/, `'${JSON.stringify(options)}'`)
|
||||
.replace(/"{{OPTIONS}}"/, `'${JSON.stringify(sessionIdOrOptions)}'`)
|
||||
return response
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user