diff --git a/.changeset/eleven-turkeys-jump.md b/.changeset/eleven-turkeys-jump.md new file mode 100644 index 000000000000..b50200cf69f0 --- /dev/null +++ b/.changeset/eleven-turkeys-jump.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +fix: decode non-latin characters when previewing prerendered pages diff --git a/packages/kit/src/exports/vite/preview/index.js b/packages/kit/src/exports/vite/preview/index.js index 2b4214e843f2..37e04f72f602 100644 --- a/packages/kit/src/exports/vite/preview/index.js +++ b/packages/kit/src/exports/vite/preview/index.js @@ -131,6 +131,13 @@ export async function preview(vite, vite_config, svelte_config) { let filename = normalizePath( join(svelte_config.kit.outDir, 'output/prerendered/pages' + pathname) ); + + try { + filename = decodeURI(filename); + } catch { + // malformed URI + } + let prerendered = is_file(filename); if (!prerendered) { diff --git "a/packages/kit/test/apps/basics/src/routes/prerendering/\344\270\255\346\226\207/+page.svelte" "b/packages/kit/test/apps/basics/src/routes/prerendering/\344\270\255\346\226\207/+page.svelte" new file mode 100644 index 000000000000..e69de29bb2d1 diff --git "a/packages/kit/test/apps/basics/src/routes/prerendering/\344\270\255\346\226\207/+page.ts" "b/packages/kit/test/apps/basics/src/routes/prerendering/\344\270\255\346\226\207/+page.ts" new file mode 100644 index 000000000000..189f71e2e1b3 --- /dev/null +++ "b/packages/kit/test/apps/basics/src/routes/prerendering/\344\270\255\346\226\207/+page.ts" @@ -0,0 +1 @@ +export const prerender = true; diff --git a/packages/kit/test/apps/basics/test/server.test.js b/packages/kit/test/apps/basics/test/server.test.js index 6590346e21b1..ff77c55f0204 100644 --- a/packages/kit/test/apps/basics/test/server.test.js +++ b/packages/kit/test/apps/basics/test/server.test.js @@ -630,6 +630,11 @@ test.describe('Miscellaneous', () => { expect(response.status()).toBe(200); expect(await response.text()).toBe('foo'); }); + + test('serves prerendered non-latin pages', async ({ request }) => { + const response = await request.get('/prerendering/中文'); + expect(response.status()).toBe(200); + }); }); test.describe('reroute', () => {