diff --git a/.changeset/proud-buses-hug.md b/.changeset/proud-buses-hug.md new file mode 100644 index 000000000000..98213f1c84a1 --- /dev/null +++ b/.changeset/proud-buses-hug.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +Decode fetched resources before checking against manifest when prerendering diff --git a/packages/kit/src/runtime/server/page/load_node.js b/packages/kit/src/runtime/server/page/load_node.js index 66a61a9ff4ca..bb878ae14b61 100644 --- a/packages/kit/src/runtime/server/page/load_node.js +++ b/packages/kit/src/runtime/server/page/load_node.js @@ -105,7 +105,7 @@ export async function load_node({ // handle fetch requests for static assets. e.g. prebaked data, etc. // we need to support everything the browser's fetch supports const prefix = options.paths.assets || options.paths.base; - const filename = ( + const filename = decodeURIComponent( resolved.startsWith(prefix) ? resolved.slice(prefix.length) : resolved ).slice(1); const filename_html = `${filename}/index.html`; // path may also match path/index.html diff --git a/packages/kit/test/prerendering/basics/src/routes/load-file-with-spaces.svelte b/packages/kit/test/prerendering/basics/src/routes/load-file-with-spaces.svelte new file mode 100644 index 000000000000..b0a3d165fac2 --- /dev/null +++ b/packages/kit/test/prerendering/basics/src/routes/load-file-with-spaces.svelte @@ -0,0 +1,25 @@ + + + + +

answer: {answer}

diff --git a/packages/kit/test/prerendering/basics/static/file with spaces.json b/packages/kit/test/prerendering/basics/static/file with spaces.json new file mode 100644 index 000000000000..6e887fd6abe8 --- /dev/null +++ b/packages/kit/test/prerendering/basics/static/file with spaces.json @@ -0,0 +1 @@ +{ "answer": 42 } diff --git a/packages/kit/test/prerendering/basics/test/test.js b/packages/kit/test/prerendering/basics/test/test.js index 16972c334eca..2cef10ee3391 100644 --- a/packages/kit/test/prerendering/basics/test/test.js +++ b/packages/kit/test/prerendering/basics/test/test.js @@ -58,4 +58,9 @@ test('renders page with unbuffered data from endpoint', () => { assert.equal(json, JSON.stringify({ answer: 42 })); }); +test('loads a file with spaces in the filename', () => { + const content = read('load-file-with-spaces/index.html'); + assert.ok(content.includes('

answer: 42

'), content); +}); + test.run();