File tree 2 files changed +27
-3
lines changed
2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -58,18 +58,18 @@ var URLStore = {
58
58
getCurrentPath : function ( ) {
59
59
if ( _location === 'history' )
60
60
return getWindowPath ( ) ;
61
-
61
+
62
62
if ( _location === 'hash' )
63
63
return window . location . hash . substr ( 1 ) ;
64
-
64
+
65
65
return _currentPath ;
66
66
} ,
67
67
68
68
/**
69
69
* Pushes the given path onto the browser navigation stack.
70
70
*/
71
71
push : function ( path ) {
72
- if ( path === _currentPath )
72
+ if ( path === this . getCurrentPath ( ) )
73
73
return ;
74
74
75
75
if ( _location === 'disabledHistory' )
@@ -193,6 +193,7 @@ var URLStore = {
193
193
}
194
194
195
195
_location = null ;
196
+ _currentPath = '/' ;
196
197
}
197
198
198
199
} ;
Original file line number Diff line number Diff line change @@ -56,3 +56,26 @@ describe('when going back in history', function () {
56
56
expect ( error ) . toEqual ( true ) ;
57
57
} ) ;
58
58
} ) ;
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
+ } ) ;
You can’t perform that action at this time.
0 commit comments