gabrielmoreira / riot-router

Riot Router - A simple routing solution for Riot
MIT License
77 stars 13 forks source link

Allow interceptors to redirect with replaceState #38

Closed soutar closed 6 years ago

soutar commented 6 years ago

This change allows interceptors to set a shouldReplace property on the response object, signalling that the redirect should be performed with replaceState rather than pushState.

router.use(function(request, response, next) {
  try {
    return next();
  } finally {
    if (request.uri != '/redirected')
      response.redirectTo = '/redirected';
      response.shouldReplace = true;
  }
});

If there's already a way to achieve this feel free to reject this PR and point me in the right direction.

gabrielmoreira commented 6 years ago

@soutar Sorry, but I have had very little time to pay attention to the project. Any reason to close the pull request? I can merge and upload the new version if you still want to.