mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-12 03:05:12 +00:00
@@ -1,4 +1,4 @@
|
||||
import { init, prefetchRoutes } from '../../../runtime.js';
|
||||
import { init, goto, prefetchRoutes } from '../../../runtime.js';
|
||||
import { Store } from 'svelte/store.js';
|
||||
import { manifest } from './manifest/client.js';
|
||||
|
||||
@@ -10,4 +10,5 @@ window.init = () => {
|
||||
});
|
||||
};
|
||||
|
||||
window.prefetchRoutes = prefetchRoutes;
|
||||
window.prefetchRoutes = prefetchRoutes;
|
||||
window.goto = goto;
|
||||
12
test/app/routes/echo/page/[slug].html
Normal file
12
test/app/routes/echo/page/[slug].html
Normal file
@@ -0,0 +1,12 @@
|
||||
<h1>{slug} ({message})</h1>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
preload({ params, query }) {
|
||||
return {
|
||||
slug: params.slug,
|
||||
message: query.message
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
15
test/app/routes/echo/server-route/[slug].js
Normal file
15
test/app/routes/echo/server-route/[slug].js
Normal file
@@ -0,0 +1,15 @@
|
||||
export function get(req, res) {
|
||||
res.writeHead(200, {
|
||||
'Content-Type': 'text/html'
|
||||
});
|
||||
|
||||
res.end(`
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head><meta charset="utf-8"></head>
|
||||
<body>
|
||||
<h1>${req.params.slug}</h1>
|
||||
</body>
|
||||
</html>
|
||||
`);
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
<a href='credentials?creds=include'>credentials</a>
|
||||
<a rel=prefetch class='{page === "blog" ? "selected" : ""}' href='blog'>blog</a>
|
||||
<a href="const">const</a>
|
||||
<a href="echo/page/encöded?message=hëllö+wörld">echo/page/encöded?message=hëllö+wörld</a>
|
||||
|
||||
<div class='hydrate-test'></div>
|
||||
|
||||
|
||||
@@ -753,6 +753,32 @@ function run({ mode, basepath = '' }) {
|
||||
assert.equal(title, 'reserved words are okay as routes');
|
||||
});
|
||||
});
|
||||
|
||||
it('encodes req.params and req.query for server-rendered pages', () => {
|
||||
return nightmare.goto(`${base}/echo/page/encöded?message=hëllö+wörld`)
|
||||
.page.title()
|
||||
.then(title => {
|
||||
assert.equal(title, 'encöded (hëllö wörld)');
|
||||
});
|
||||
});
|
||||
|
||||
it('encodes req.params and req.query for client-rendered pages', () => {
|
||||
return nightmare.goto(base).init()
|
||||
.click('a[href="echo/page/encöded?message=hëllö+wörld"]')
|
||||
.wait(100)
|
||||
.page.title()
|
||||
.then(title => {
|
||||
assert.equal(title, 'encöded (hëllö wörld)');
|
||||
});
|
||||
});
|
||||
|
||||
it('encodes req.params for server routes', () => {
|
||||
return nightmare.goto(`${base}/echo/server-route/encöded`)
|
||||
.page.title()
|
||||
.then(title => {
|
||||
assert.equal(title, 'encöded');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('headers', () => {
|
||||
|
||||
Reference in New Issue
Block a user