Merge pull request #162 from sveltejs/gh-103

URI-encode routes
This commit is contained in:
Rich Harris
2018-03-04 19:11:22 -05:00
committed by GitHub
3 changed files with 11 additions and 2 deletions

View File

@@ -33,8 +33,8 @@ export default function create_routes({ files } = { files: glob.sync('**/*.+(htm
let i = parts.length;
let nested = true;
while (i--) {
const part = parts[i];
const dynamic = part[0] === '[';
const part = encodeURIComponent(parts[i].normalize()).replace(/%5B/g, '[').replace(/%5D/g, ']');
const dynamic = ~part.indexOf('[');
if (dynamic) {
const matcher = part.replace(param_pattern, `([^\/]+?)`);

View File

@@ -0,0 +1 @@
<h1>I'm afraid I just blue myself</h1>

View File

@@ -403,6 +403,14 @@ function run(env) {
assert.equal(text, 'nope');
});
});
it('encodes routes', () => {
return nightmare.goto(`${base}/fünke`)
.page.title()
.then(title => {
assert.equal(title, `I'm afraid I just blue myself`);
});
});
});
describe('headers', () => {