File tree Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ export class History {
1818 go: ( n : number ) => void ;
1919 push: ( loc : RawLocation ) => void ;
2020 replace: ( loc : RawLocation ) => void ;
21- ensureURL: ( ) => void ;
21+ ensureURL: ( push ? : boolean ) => void ;
2222
2323 constructor ( router : VueRouter , base : ?string ) {
2424 this . router = router
@@ -70,7 +70,7 @@ export class History {
7070 hook ( route , current , ( to : any ) => {
7171 if ( to === false ) {
7272 // next(false) -> abort navigation, ensure current URL
73- this . ensureURL ( )
73+ this . ensureURL ( true )
7474 } else if ( typeof to === 'string' || typeof to === 'object' ) {
7575 // next('/') or next({ path: '/' }) -> redirect
7676 this . push ( to )
Original file line number Diff line number Diff line change @@ -52,9 +52,10 @@ export class HashHistory extends History {
5252 window . history . go ( n )
5353 }
5454
55- ensureURL ( ) {
56- if ( getHash ( ) !== this . current . fullPath ) {
57- replaceHash ( this . current . fullPath )
55+ ensureURL ( push ?: boolean ) {
56+ const current = this . current . fullPath
57+ if ( getHash ( ) !== current ) {
58+ push ? pushHash ( current ) : replaceHash ( current )
5859 }
5960 }
6061}
Original file line number Diff line number Diff line change @@ -57,9 +57,10 @@ export class HTML5History extends History {
5757 } )
5858 }
5959
60- ensureURL ( ) {
60+ ensureURL ( push ?: boolean ) {
6161 if ( getLocation ( this . base ) !== this . current . fullPath ) {
62- replaceState ( cleanPath ( this . base + this . current . fullPath ) )
62+ const current = cleanPath ( this . base + this . current . fullPath )
63+ push ? pushState ( current ) : replaceState ( current )
6364 }
6465 }
6566
You can’t perform that action at this time.
0 commit comments