Archived
1
0

feat: persist route query to local

Provide a way for the shell script running in the docker container to get the url query.
This commit is contained in:
fxxjdedd 2020-07-28 20:14:52 +08:00 committed by GitHub
parent 638ab7c557
commit 5ba650bb6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -134,6 +134,7 @@ export class VscodeHttpProvider extends HttpProvider {
return { redirect: "/login", query: { to: this.options.base } } return { redirect: "/login", query: { to: this.options.base } }
} }
try { try {
this.persistRouteQuery(request, route)
return await this.getRoot(request, route) return await this.getRoot(request, route)
} catch (error) { } catch (error) {
const message = `<div>VS Code failed to load.</div> ${ const message = `<div>VS Code failed to load.</div> ${
@ -165,6 +166,13 @@ export class VscodeHttpProvider extends HttpProvider {
throw new HttpError("Not found", HttpCode.NotFound) throw new HttpError("Not found", HttpCode.NotFound)
} }
private persistRouteQuery(request: http.IncomingMessage, route: Route): void {
const content = Object.keys(route.query).reduce((content, next) => {
return (content += `${next}=${route.query[next]}\n`)
}, "")
fs.writeFile(path.resolve(paths.data, "query"), content)
}
private async getRoot(request: http.IncomingMessage, route: Route): Promise<HttpResponse> { private async getRoot(request: http.IncomingMessage, route: Route): Promise<HttpResponse> {
const remoteAuthority = request.headers.host as string const remoteAuthority = request.headers.host as string
const { lastVisited } = await settings.read() const { lastVisited } = await settings.read()