fix: replace leading slash in preload’s redirect

This commit is contained in:
Luke Edwards
2018-08-06 20:22:33 -07:00
parent 666c113297
commit aad87857ce

View File

@@ -336,6 +336,7 @@ function get_page_handler(manifest: Manifest, store_getter: (req: Req) => Store)
if (redirect && (redirect.statusCode !== statusCode || redirect.location !== location)) {
throw new Error(`Conflicting redirects`);
}
location = location.replace(/^\//g, ''); // leading slash (only)
redirect = { statusCode, location };
},
error: (statusCode: number, message: Error | string) => {
@@ -582,4 +583,4 @@ function escape_html(html: string) {
};
return html.replace(/["'&<>]/g, c => `&${chars[c]};`);
}
}