Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions runtime/src/server/middleware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,14 @@ export function serve({ prefix, pathname, cache_control }: {
res.setHeader('Cache-Control', cache_control);
res.end(data);
} catch (err) {
res.statusCode = 404;
res.end('not found');
// [#1442](https://github.com/sveltejs/sapper/issues/1142)
// Requests to addresses under "/client" cannot be filtered out on their prefix, and can therefore end up here.
if (req.path.startsWith(prefix) && !/\..*$/.test(req.path)) {
next();
} else {
res.statusCode = 404;
res.end('not found');
}
}
} else {
next();
Expand Down
1 change: 1 addition & 0 deletions test/apps/basics/src/routes/apple/new.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Success.
1 change: 1 addition & 0 deletions test/apps/basics/src/routes/client/client/new.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Success.</h1>
1 change: 1 addition & 0 deletions test/apps/basics/src/routes/client/index.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Success.</h1>
1 change: 1 addition & 0 deletions test/apps/basics/src/routes/client/new.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Success.</h1>
9 changes: 9 additions & 0 deletions test/apps/basics/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,15 @@ describe('basics', function() {
assert.equal(await r.text('h2'), 'Called 1 time');
});

it('finds routes under /client/', async () => {
await r.load('/client');
assert.equal(await r.text('h1'), 'Success.');
await r.load('/client/new');
assert.equal(await r.text('h1'), 'Success.');
await r.load('/client/client/new');
assert.equal(await r.text('h1'), 'Success.');
});

it('survives the tests with no server errors', () => {
assert.deepEqual(r.errors, []);
});
Expand Down