Skip to content

Commit

Permalink
[fix] decode path only once to fix loading unicode routes
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Aug 11, 2021
1 parent c3ca3fb commit ecc6080
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/adapter-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"tiny-glob": "^0.2.9"
},
"devDependencies": {
"@polka/url": "^1.0.0-next.15",
"@rollup/plugin-json": "^4.1.0",
"@sveltejs/kit": "workspace:*",
"c8": "^7.7.2",
Expand Down
9 changes: 8 additions & 1 deletion packages/adapter-node/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import compression from 'compression';
import fs from 'fs';
import { dirname, join } from 'path';
import polka from 'polka';
import { parse } from '@polka/url';
import sirv from 'sirv';
import { fileURLToPath } from 'url';

Expand Down Expand Up @@ -38,7 +39,13 @@ export function createServer({ render }) {
})
: noop_handler;

const server = polka().use(
const server = polka();
// Polka has a non-standard behavior of decoding the request path
// Disable it so that we don't double-decode. SvelteKit will handle decoding
server.parse = (req) => {
return parse(req, false);
};
server.use(
compression({ threshold: 0 }),
assets_handler,
prerendered_handler,
Expand Down
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ecc6080

Please sign in to comment.