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 {
17
17
go: ( n : number ) => void ;
18
18
push: ( loc : RawLocation ) => void ;
19
19
replace: ( loc : RawLocation ) => void ;
20
- ensureURL: ( ) => void ;
20
+ ensureURL: ( push ? : boolean ) => void ;
21
21
22
22
constructor ( router : VueRouter , base : ?string ) {
23
23
this . router = router
@@ -69,7 +69,7 @@ export class History {
69
69
hook ( route , current , ( to : any ) => {
70
70
if ( to === false ) {
71
71
// next(false) -> abort navigation, ensure current URL
72
- this . ensureURL ( )
72
+ this . ensureURL ( true )
73
73
} else if ( typeof to === 'string' || typeof to === 'object' ) {
74
74
// next('/') or next({ path: '/' }) -> redirect
75
75
this . push ( to )
Original file line number Diff line number Diff line change @@ -57,9 +57,10 @@ export class HashHistory extends History {
57
57
window . history . go ( n )
58
58
}
59
59
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 )
63
64
}
64
65
}
65
66
}
Original file line number Diff line number Diff line change @@ -59,9 +59,10 @@ export class HTML5History extends History {
59
59
} )
60
60
}
61
61
62
- ensureURL ( ) {
62
+ ensureURL ( push ?: boolean ) {
63
63
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 )
65
66
}
66
67
}
67
68
You can’t perform that action at this time.
0 commit comments