Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(react-server): decode dynamic route params #271

Merged
merged 4 commits into from Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/react-server/examples/basic/e2e/basic.test.ts
Expand Up @@ -727,6 +727,14 @@ test("dynamic routes", async ({ page }) => {
await page.getByText("file: /test/dynamic/[id]/[nested]/page.tsx").click();
await page.getByText("pathname: /test/dynamic/abc/def").click();
await page.getByText('params: {"id":"abc","nested":"def"}').click();

await page.getByRole("link", { name: "/test/dynamic/🎸 + 🎷 = 🎶" }).click();
await page.getByText('params: {"id":"🎸 + 🎷 = 🎶"}').click();
await page.waitForURL("/test/dynamic/🎸 + 🎷 = 🎶");

await page.getByRole("link", { name: "/test/dynamic/%F0%9F%8E%B8%" }).click();
await page.getByText('params: {"id":"🎸 + 🎷 = 🎶"}').click();
await page.waitForURL("/test/dynamic/🎸 + 🎷 = 🎶");
});

test("full client route", async ({ page }) => {
Expand Down
Expand Up @@ -11,6 +11,8 @@ export default function Layout(props: LayoutProps) {
"/test/dynamic",
"/test/dynamic/static",
"/test/dynamic/abc",
"/test/dynamic/🎸 + 🎷 = 🎶",
"/test/dynamic/" + encodeURI("🎸 + 🎷 = 🎶"),
"/test/dynamic/abc/def",
]}
/>
Expand Down
2 changes: 1 addition & 1 deletion packages/react-server/src/lib/router.tsx
Expand Up @@ -106,7 +106,7 @@ export async function renderRouteMap(
if (next?.child) {
node = next.child;
if (next.param) {
params = { ...params, [next.param]: key };
params = { ...params, [next.param]: decodeURI(key) };
}
} else {
node = initNode();
Expand Down