Skip to content

Commit

Permalink
Fix redirects (#3808)
Browse files Browse the repository at this point in the history
Only need to create the location in match.

Fixes #3807
  • Loading branch information
taion authored and timdorr committed Sep 13, 2016
1 parent 4f3ea90 commit 6b231fb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
7 changes: 1 addition & 6 deletions modules/createTransitionManager.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import warning from './routerWarning'
import { REPLACE } from 'history/lib/Actions'
import computeChangedRoutes from './computeChangedRoutes'
import { runEnterHooks, runChangeHooks, runLeaveHooks } from './TransitionUtils'
import _isActive from './isActive'
Expand Down Expand Up @@ -43,10 +42,6 @@ export default function createTransitionManager(history, routes) {
)
}

function createLocationFromRedirectInfo(location) {
return history.createLocation(location, REPLACE)
}

let partialNextState

function match(location, callback) {
Expand Down Expand Up @@ -104,7 +99,7 @@ export default function createTransitionManager(history, routes) {

function handleErrorOrRedirect(error, redirectInfo) {
if (error) callback(error)
else callback(null, createLocationFromRedirectInfo(redirectInfo))
else callback(null, redirectInfo)
}
}

Expand Down
3 changes: 2 additions & 1 deletion modules/match.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { REPLACE } from 'history/lib/Actions'
import invariant from 'invariant'

import createMemoryHistory from './createMemoryHistory'
Expand Down Expand Up @@ -45,7 +46,7 @@ function match({ history, routes, location, ...options }, callback) {
transitionManager.match(location, function (error, redirectLocation, nextState) {
callback(
error,
redirectLocation,
redirectLocation && router.createLocation(redirectLocation, REPLACE),
nextState && {
...nextState,
history,
Expand Down

0 comments on commit 6b231fb

Please sign in to comment.