Skip to content

Commit

Permalink
Merge pull request #1337 from weaveworks/1335-nodes-with-a-slash
Browse files Browse the repository at this point in the history
Fixes nodes w/ a slash under a path-prefixed scope.
  • Loading branch information
foot committed Apr 18, 2016
2 parents c3d5a79 + eb86473 commit b95e97c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions client/app/scripts/utils/router-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import page from 'page';
import { route } from '../actions/app-actions';
import AppStore from '../stores/app-store';

//
// page.js won't match the routes below if ":state" has a slash in it, so replace those before we
// load the state into the URL.
//
const SLASH_REPLACEMENT = '<SLASH>';

function shouldReplaceState(prevState, nextState) {
// Opening a new terminal while an existing one is open.
const terminalToTerminal = (prevState.controlPipe && nextState.controlPipe);
Expand All @@ -14,12 +20,12 @@ function shouldReplaceState(prevState, nextState) {

export function updateRoute() {
const state = AppStore.getAppState();
const stateUrl = JSON.stringify(state);
const stateUrl = JSON.stringify(state).replace('/', SLASH_REPLACEMENT);
const dispatch = false;
const urlStateString = window.location.hash
.replace('#!/state/', '')
.replace('#!/', '') || '{}';
const prevState = JSON.parse(decodeURIComponent(urlStateString));
const prevState = JSON.parse(decodeURIComponent(urlStateString.replace(SLASH_REPLACEMENT, '/')));

if (shouldReplaceState(prevState, state)) {
// Replace the top of the history rather than pushing on a new item.
Expand Down

0 comments on commit b95e97c

Please sign in to comment.