Skip to content

Commit

Permalink
[core.http] Cleanup catch-all route for paths with trailing slashes. (e…
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeelmers authored Apr 20, 2021
1 parent 2f3139c commit fa06191
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/server/core_app/core_app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class CoreApp {
async (context, req, res) => {
const { query, params } = req;
const { path } = params;
if (!path || !path.endsWith('/')) {
if (!path || !path.endsWith('/') || path.startsWith('/')) {
return res.notFound();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ describe('Core app routes', () => {
expect(response.get('location')).toEqual('/base-path/some-path?foo=bar');
});

it('does not redirect if the path starts with `//`', async () => {
await kbnTestServer.request.get(root, '//some-path/').expect(404);
});

it('does not redirect if the path does not end with `/`', async () => {
await kbnTestServer.request.get(root, '/some-path').expect(404);
});
Expand Down

0 comments on commit fa06191

Please sign in to comment.