Preserve query variables when redirecting

This commit is contained in:
Asher 2019-08-12 11:46:58 -05:00
parent 5539519691
commit 90e8714e71
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A

View File

@ -189,7 +189,8 @@ export abstract class Server {
}
protected withBase(request: http.IncomingMessage, path: string): string {
return `${this.protocol}://${request.headers.host}${this.options.basePath}${path}`;
const split = request.url ? request.url.split("?", 2) : [];
return `${this.protocol}://${request.headers.host}${this.options.basePath}${path}${split.length === 2 ? `?${split[1]}` : ""}`;
}
private onRequest = async (request: http.IncomingMessage, response: http.ServerResponse): Promise<void> => {