diff --git a/src/middleware.ts b/src/middleware.ts index 6941ab3..5d1e6b0 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -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]};`); -} \ No newline at end of file +}