Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit 24bfcc8

Browse files
authored
Merge pull request #162 from sveltejs/gh-103
URI-encode routes
2 parents ef0ca58 + b405e58 commit 24bfcc8

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/core/create_routes.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export default function create_routes({ files } = { files: glob.sync('**/*.+(htm
3333
let i = parts.length;
3434
let nested = true;
3535
while (i--) {
36-
const part = parts[i];
37-
const dynamic = part[0] === '[';
36+
const part = encodeURIComponent(parts[i].normalize()).replace(/%5B/g, '[').replace(/%5D/g, ']');
37+
const dynamic = ~part.indexOf('[');
3838

3939
if (dynamic) {
4040
const matcher = part.replace(param_pattern, `([^\/]+?)`);

test/app/routes/fünke.html

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>I'm afraid I just blue myself</h1>

test/common/test.js

+8
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,14 @@ function run(env) {
403403
assert.equal(text, 'nope');
404404
});
405405
});
406+
407+
it('encodes routes', () => {
408+
return nightmare.goto(`${base}/fünke`)
409+
.page.title()
410+
.then(title => {
411+
assert.equal(title, `I'm afraid I just blue myself`);
412+
});
413+
});
406414
});
407415

408416
describe('headers', () => {

0 commit comments

Comments
 (0)