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 @@ -17,7 +17,7 @@ export class History {
1717 go: ( n : number ) => void ;
1818 push: ( loc : RawLocation ) => void ;
1919 replace: ( loc : RawLocation ) => void ;
20- ensureURL: ( ) => void ;
20+ ensureURL: ( push ? : boolean ) => void ;
2121
2222 constructor ( router : VueRouter , base : ?string ) {
2323 this . router = router
@@ -69,7 +69,7 @@ export class History {
6969 hook ( route , current , ( to : any ) => {
7070 if ( to === false ) {
7171 // next(false) -> abort navigation, ensure current URL
72- this . ensureURL ( )
72+ this . ensureURL ( true )
7373 } else if ( typeof to === 'string' || typeof to === 'object' ) {
7474 // next('/') or next({ path: '/' }) -> redirect
7575 this . push ( to )
Original file line number Diff line number Diff line change @@ -57,9 +57,10 @@ export class HashHistory extends History {
5757 window . history . go ( n )
5858 }
5959
60- ensureURL ( ) {
61- if ( getHash ( ) !== this . current . fullPath ) {
62- pushHash ( this . current . fullPath )
60+ ensureURL ( push ?: boolean ) {
61+ const current = this . current . fullPath
62+ if ( getHash ( ) !== current ) {
63+ push ? pushHash ( current ) : replaceHash ( current )
6364 }
6465 }
6566}
Original file line number Diff line number Diff line change @@ -59,9 +59,10 @@ export class HTML5History extends History {
5959 } )
6060 }
6161
62- ensureURL ( ) {
62+ ensureURL ( push ?: boolean ) {
6363 if ( getLocation ( this . base ) !== this . current . fullPath ) {
64- pushState ( cleanPath ( this . base + this . current . fullPath ) )
64+ const current = cleanPath ( this . base + this . current . fullPath )
65+ push ? pushState ( current ) : replaceState ( current )
6566 }
6667 }
6768
You can’t perform that action at this time.
0 commit comments