Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Apr 18, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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