router.js
router.js copied to clipboard
Strict exit
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.