Skip to content

Commit

Permalink
Query parameters are not included in params
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiel committed Apr 22, 2020
1 parent c8e57c1 commit 8c42462
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/router.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,15 @@ describe('Router', () => {
testEngine.simulateNavigation('/john');
}));

test('query string is not included', () =>
new Promise((resolve) => {
router.get('/:name', (req) => {
expect(req.params).toHaveProperty('name', 'john');
resolve();
});
testEngine.simulateNavigation('/john?key=value');
}));

test('param can be taken by "get" function', () =>
new Promise((resolve) => {
router.get('/:name', (req) => {
Expand Down
3 changes: 2 additions & 1 deletion src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ const createExecuteRoutes = (context: RouteContext) => {
const route = matchedRoutes[0];
const params: { [p: string]: string } = {};
const splats = [];
const match = path.match(route.path);
const [pathWithoutQuery] = path.split('?');
const match = pathWithoutQuery.match(route.path);
/* istanbul ignore else */
if (match) {
let j = 0;
Expand Down

0 comments on commit 8c42462

Please sign in to comment.