Skip to content

Commit

Permalink
Always goBack when using RefreshLocation
Browse files Browse the repository at this point in the history
  • Loading branch information
mjackson committed Dec 16, 2014
1 parent efdd34d commit 8897782
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/utils/History.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var canUseDOM = require('react/lib/ExecutionEnvironment').canUseDOM;
var History = {

/**
* Sends the browser back one entry in the history, if one is available.
* Sends the browser back one entry in the history.
*/
back: function () {
invariant(
Expand Down
13 changes: 10 additions & 3 deletions modules/utils/createRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,23 @@ function createRouter(options) {
},

/**
* Transitions to the previous URL. Returns true if the router
* was able to go back, false otherwise.
* Transitions to the previous URL if one is available. Returns true if the
* router was able to go back, false otherwise.
*
* Note: The router only tracks history entries in your application, not the
* current browser session, so you can safely call this function without guarding
* against sending the user back to some other site. However, when using
* RefreshLocation (which is the fallback for HistoryLocation in browsers that
* don't support HTML5 history) this method will *always* send the client back
* because we cannot reliably track history length.
*/
goBack: function () {
invariant(
typeof location !== 'string',
'You cannot use goBack with a static location'
);

if (History.length > 1) {
if (History.length > 1 || location === RefreshLocation) {
location.pop();
return true;
}
Expand Down

0 comments on commit 8897782

Please sign in to comment.