From 0f421d72221495b8ef14195db3e3df9297ebc6ff Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Tue, 8 Aug 2023 12:38:05 +0530 Subject: [PATCH] fix(build): nested rewrites not working properly --- src/node/plugins/rewritesPlugin.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node/plugins/rewritesPlugin.ts b/src/node/plugins/rewritesPlugin.ts index 2388a70a8ef6..51794a1dbd36 100644 --- a/src/node/plugins/rewritesPlugin.ts +++ b/src/node/plugins/rewritesPlugin.ts @@ -7,7 +7,7 @@ export function resolveRewrites( userRewrites: UserConfig['rewrites'] ) { const rewriteRules = Object.entries(userRewrites || {}).map(([from, to]) => ({ - toPath: compile(to, { validate: false }), + toPath: compile(`/${to}`, { validate: false }), matchUrl: match(from.startsWith('^') ? new RegExp(from) : from) })) @@ -18,7 +18,7 @@ export function resolveRewrites( for (const { matchUrl, toPath } of rewriteRules) { const res = matchUrl(page) if (res) { - const dest = toPath(res.params) + const dest = toPath(res.params).slice(1) pageToRewrite[page] = dest rewriteToPage[dest] = page break