Skip to content

Commit 90a11d9

Browse files
authoredMay 21, 2024··
fix(core): fix page redirects comparison (#1563)
1 parent cf03532 commit 90a11d9

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed
 

‎packages/core/src/app/prepare/prepareRoutes.ts

+7-12
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,15 @@ const resolvePageRedirects = ({ path, pathInferred }: Page): string[] => {
2727
// paths that should redirect to this page, use set to dedupe
2828
const redirectsSet = new Set<string>()
2929

30-
// add redirect to the set when the redirect could not be normalized & encoded to the page path
31-
const addRedirect = (redirect: string): void => {
32-
const normalizedPath = normalizeRoutePath(redirect)
33-
if (normalizedPath === path) return
34-
35-
const encodedPath = encodeURI(normalizedPath)
36-
if (encodedPath === path) return
37-
38-
redirectsSet.add(redirect)
39-
}
40-
4130
// redirect from inferred path, notice that the inferred path is not uri-encoded
4231
if (pathInferred !== null) {
43-
addRedirect(encodeURI(pathInferred))
32+
const normalizedPathInferred = normalizeRoutePath(pathInferred)
33+
const encodedPathInferred = encodeURI(normalizedPathInferred)
34+
35+
// add redirect to the set when the redirect could not be normalized & encoded to the page path
36+
if (normalizedPathInferred !== path && encodedPathInferred !== path) {
37+
redirectsSet.add(encodedPathInferred)
38+
}
4439
}
4540

4641
return Array.from(redirectsSet)

0 commit comments

Comments
 (0)
Please sign in to comment.