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

Pull request to resolve issue #1442 #1197

Closed
wants to merge 1 commit into from
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
7 changes: 6 additions & 1 deletion runtime/src/server/middleware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,14 @@ export function serve({ prefix, pathname, cache_control }: {
pathname?: string,
cache_control: string
}) {
// Filter requests based on req.path.
const filter = pathname
? (req: Req) => req.path === pathname
: (req: Req) => req.path.startsWith(prefix);
/*
* [#1442](https://github.com/sveltejs/sapper/issues/1142)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it looks weird that this line is indented more than the previous line that starts the comment. also, usually I would just use the // syntax for a two line comment in the middle of the code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your feedback, I have withdrawn the pull request to improve it. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can update existing requests. you just make the change, run git commit, and then git push and it will update the pull request

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didnt' work out yet, will continue this evening..

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can update existing requests. you just make the change, run git commit, and then git push and it will update the pull request

I'll keep that in mind for any future pull requests I want to update. For now, I took a large detour on updating the pull request..

* Exception: Ensure an extension exists in the pathname, to filter out the first request to routes under "/client/".
*/
: (req: Req) => req.path.startsWith(prefix) && /\..*$/.test(req.path);

const cache: Map<string, Buffer> = new Map();

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 @@ -386,4 +386,13 @@ describe('basics', function() {
it('survives the tests with no server errors', () => {
assert.deepEqual(r.errors, []);
});

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.');
})
});