Skip to content

Commit

Permalink
feat(router): consolidate / for "hash and pushstate"
Browse files Browse the repository at this point in the history
  • Loading branch information
jwx committed Aug 25, 2019
1 parent dbf5449 commit 6492182
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/router/src/browser-navigator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ export class BrowserNavigator implements INavigatorStore, INavigatorViewer {

public pushNavigatorState(state: INavigatorState): Promise<void> {
const { title, path } = state.currentEntry;
const fragment = this.options.useBrowserFragmentHash ? '#' : '';
const fragment = this.options.useBrowserFragmentHash ? '#/' : '';
return this.enqueue(this.history, 'pushState', [state, title, `${fragment}${path}`]);
}

public replaceNavigatorState(state: INavigatorState): Promise<void> {
const { title, path } = state.currentEntry;
const fragment = this.options.useBrowserFragmentHash ? '#' : '';
const fragment = this.options.useBrowserFragmentHash ? '#/' : '';
return this.enqueue(this.history, 'replaceState', [state, title, `${fragment}${path}`]);
}

Expand Down
4 changes: 4 additions & 0 deletions packages/router/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ export class Router implements IRouter {
// TODO: Don't go via string here, use instructions as they are
path = Array.isArray(routeOrInstructions) ? this.instructionResolver.stringifyViewportInstructions(routeOrInstructions) : routeOrInstructions;
}
// TODO: Review this
if (path === '/') {
path = '';
}

// TODO: Clean up clear viewports
const { clear, newPath } = this.instructionResolver.shouldClearViewports(path);
Expand Down

0 comments on commit 6492182

Please sign in to comment.