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