Fixes nodes w/ a slash under a path-prefixed scope.

E.g. localhost:4043/scoped/{state:{label:"/zing"...

Double encode is solution!
 - https://github.com/visionmedia/page.js/issues/187
This commit is contained in:
Simon Howe
2016-04-18 19:17:06 +02:00
parent c3d5a79e61
commit 85bfc25bec

View File

@@ -14,12 +14,12 @@ function shouldReplaceState(prevState, nextState) {
export function updateRoute() {
const state = AppStore.getAppState();
const stateUrl = JSON.stringify(state);
const stateUrl = encodeURIComponent(encodeURIComponent(JSON.stringify(state)));
const dispatch = false;
const urlStateString = window.location.hash
.replace('#!/state/', '')
.replace('#!/', '') || '{}';
const prevState = JSON.parse(decodeURIComponent(urlStateString));
const prevState = JSON.parse(decodeURIComponent(decodeURIComponent(urlStateString)));
if (shouldReplaceState(prevState, state)) {
// Replace the top of the history rather than pushing on a new item.