Skip to content
Permalink
Browse files

fixup! feat(router): add hash-based navigation option to setUpLocatio…

…nSync
  • Loading branch information...
jasonaden committed Feb 13, 2019
1 parent fa1db49 commit 515ae500cd6773818eeefaaf551aa11f9ba48294
Showing with 4 additions and 3 deletions.
  1. +3 −2 packages/router/upgrade/src/upgrade.ts
  2. +1 −1 packages/router/upgrade/test/upgrade.spec.ts
@@ -75,8 +75,9 @@ export function setUpLocationSync(ngUpgrade: UpgradeModule, urlType: 'path' | 'h
if (urlType === 'path') {
url = resolveUrl(next);
} else if (urlType === 'hash') {
// Remove the leading hash from the URL
url = resolveUrl(next.substring(1));
// Remove the first hash from the URL
const hashIdx = next.indexOf('#');
url = resolveUrl(next.substring(0, hashIdx) + next.substring(hashIdx + 1));
} else {
throw 'Invalid URLType passed to setUpLocationSync: ' + urlType;
}
@@ -97,7 +97,7 @@ describe('setUpLocationSync', () => {
callback({}, combinedUrl, '');

expect(LocationMock.normalize).toHaveBeenCalledTimes(1);
expect(LocationMock.normalize).toHaveBeenCalledWith(pathname + query + hash);
expect(LocationMock.normalize).toHaveBeenCalledWith(pathname);

expect(RouterMock.navigateByUrl).toHaveBeenCalledTimes(1);
expect(RouterMock.navigateByUrl).toHaveBeenCalledWith(normalizedPathname + query + hash);

0 comments on commit 515ae50

Please sign in to comment.
You can’t perform that action at this time.