Skip to content
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
2 changes: 1 addition & 1 deletion src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const exec = (url, route, matches = {}) => {
// segment match:
if (!m && param == val) continue;
// /foo/* match
if (!m && val && flag == '*') {
if (!m && flag == '*') {
matches.rest = '/' + url.slice(i).map(decodeURIComponent).join('/');
break;
}
Expand Down
3 changes: 3 additions & 0 deletions test/node/router-match.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ test('Param rest segment', () => {
const accurateResult = execPath('/user/foo', '/user/*');
assert.equal(accurateResult, { path: '/user/foo', params: {}, query: {}, rest: '/foo' });

const accurateResult2 = execPath('/user', '/user/*');
assert.equal(accurateResult2, { path: '/user', params: {}, query: {}, rest: '/' });

const inaccurateResult = execPath('/', '/user/:id/*');
assert.equal(inaccurateResult, undefined);
});
Expand Down