diff --git a/src/browser/media/manifest.json b/src/browser/media/manifest.json index 513304e1..0b9a7e1d 100644 --- a/src/browser/media/manifest.json +++ b/src/browser/media/manifest.json @@ -1,12 +1,12 @@ { "name": "code-server", "short_name": "code-server", - "start_url": "../../../..", + "start_url": "{{BASE}}", "display": "fullscreen", "background-color": "#fff", "description": "Run editors on a remote server.", "icons": [{ - "src": "./code-server.png", + "src": "{{BASE}}/static-{{COMMIT}}/src/browser/media/code-server.png", "sizes": "384x384", "type": "image/png" }] diff --git a/src/node/app/app.ts b/src/node/app/app.ts index c80fb0b7..8c65e0f7 100644 --- a/src/node/app/app.ts +++ b/src/node/app/app.ts @@ -24,7 +24,7 @@ export class MainHttpProvider extends HttpProvider { switch (route.base) { case "/static": { this.ensureMethod(request) - const response = await this.getResource(this.rootPath, route.requestPath) + const response = await this.getReplacedResource(route) if (!this.isDev) { response.cache = true } @@ -75,6 +75,20 @@ export class MainHttpProvider extends HttpProvider { return this.getErrorRoot(route, "404", "404", "Application not found") } + /** + * Return a resource with variables replaced where necessary. + */ + protected async getReplacedResource(route: Route): Promise { + if (route.requestPath.endsWith("/manifest.json")) { + const response = await this.getUtf8Resource(this.rootPath, route.requestPath) + response.content = response.content + .replace(/{{BASE}}/g, this.base(route)) + .replace(/{{COMMIT}}/g, this.options.commit) + return response + } + return this.getResource(this.rootPath, route.requestPath) + } + public async getRoot(route: Route): Promise { const recent = await this.api.recent() const apps = await this.api.installedApplications()