router.js icon indicating copy to clipboard operation
router.js copied to clipboard

Strict exit

Open ramiel opened this issue 4 years ago • 0 comments

The exit handler is ambigous. Given the following routes

router
  .get('/posts/:page?', handler)
  .exit('/posts/:page?', exitHandler);

If I navigate from /posts/1 to /posts/2, should the exitHandler run?

The page is changing but the overall url structure is not.

A good solution can be to add a third parameter to .exit accepting options. One option can be strict and by default is false.

If false the behavior is that exit is run when the url changes, without any further check.
if true the exit handler run only if the next url is not a match for the exit path.

ramiel avatar Nov 12 '19 11:11 ramiel