fix(build): nested rewrites not working properly

pull/2750/head
Divyansh Singh 1 year ago
parent 481a5e3cb5
commit 0f421d7222

@ -7,7 +7,7 @@ export function resolveRewrites(
userRewrites: UserConfig['rewrites'] userRewrites: UserConfig['rewrites']
) { ) {
const rewriteRules = Object.entries(userRewrites || {}).map(([from, to]) => ({ 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) matchUrl: match(from.startsWith('^') ? new RegExp(from) : from)
})) }))
@ -18,7 +18,7 @@ export function resolveRewrites(
for (const { matchUrl, toPath } of rewriteRules) { for (const { matchUrl, toPath } of rewriteRules) {
const res = matchUrl(page) const res = matchUrl(page)
if (res) { if (res) {
const dest = toPath(res.params) const dest = toPath(res.params).slice(1)
pageToRewrite[page] = dest pageToRewrite[page] = dest
rewriteToPage[dest] = page rewriteToPage[dest] = page
break break

Loading…
Cancel
Save