mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 02:00:43 +00:00
Fixed url state copy/paste bug
This commit is contained in:
@@ -90,20 +90,21 @@ export function updateRoute(getState) {
|
||||
|
||||
|
||||
export function getRouter(dispatch, initialState) {
|
||||
let mergedState = initialState;
|
||||
// strip any trailing '/'s.
|
||||
page.base(window.location.pathname.replace(/\/$/, ''));
|
||||
|
||||
const storageState = storageGet(STORAGE_STATE_KEY);
|
||||
if (storageState) {
|
||||
window.location.hash = `!/state/${storageState}`;
|
||||
const parsedState = JSON.parse(decodeURL(storageState));
|
||||
mergedState = { ...initialState, ...parsedState };
|
||||
}
|
||||
|
||||
page('/', () => {
|
||||
// recover from storage state on empty URL
|
||||
dispatch(route(mergedState));
|
||||
const storageState = storageGet(STORAGE_STATE_KEY);
|
||||
if (storageState) {
|
||||
// push storage state to URL
|
||||
window.location.hash = `!/state/${storageState}`;
|
||||
const parsedState = JSON.parse(decodeURL(storageState));
|
||||
const mergedState = Object.assign(initialState, parsedState);
|
||||
dispatch(route(mergedState));
|
||||
} else {
|
||||
dispatch(route(initialState));
|
||||
}
|
||||
});
|
||||
|
||||
page('/state/:state', (ctx) => {
|
||||
|
||||
Reference in New Issue
Block a user