Skip to content

Commit 33695b4

Browse files
committedAug 4, 2014
Merge pull request #163 from bripkens/failing-navigation
[fixed] Navigation to root URL can fail
2 parents a597441 + 87b1c2a commit 33695b4

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed
 

‎modules/stores/URLStore.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,18 @@ var URLStore = {
5858
getCurrentPath: function () {
5959
if (_location === 'history')
6060
return getWindowPath();
61-
61+
6262
if (_location === 'hash')
6363
return window.location.hash.substr(1);
64-
64+
6565
return _currentPath;
6666
},
6767

6868
/**
6969
* Pushes the given path onto the browser navigation stack.
7070
*/
7171
push: function (path) {
72-
if (path === _currentPath)
72+
if (path === this.getCurrentPath())
7373
return;
7474

7575
if (_location === 'disabledHistory')
@@ -193,6 +193,7 @@ var URLStore = {
193193
}
194194

195195
_location = null;
196+
_currentPath = '/';
196197
}
197198

198199
};

‎specs/URLStore.spec.js

+23
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,26 @@ describe('when going back in history', function () {
5656
expect(error).toEqual(true);
5757
});
5858
});
59+
60+
describe('when navigating back to the root', function() {
61+
beforeEach(function () {
62+
// not all tests are constructing and tearing down the URLStore.
63+
// Let's set it up correctly once and then tear it down to ensure that all
64+
// variables in the URLStore module are reset.
65+
URLStore.setup('hash');
66+
URLStore.teardown();
67+
68+
// simulating that the browser opens a page with #/dashboard
69+
window.location.hash = '/dashboard';
70+
URLStore.setup('hash');
71+
});
72+
73+
afterEach(function () {
74+
URLStore.teardown();
75+
});
76+
77+
it('should have the correct path', function () {
78+
URLStore.push('/');
79+
expect(window.location.hash).toEqual('#/');
80+
});
81+
});

0 commit comments

Comments
 (0)
Please sign in to comment.