@@ -9,7 +9,7 @@ function normalizeLocation(rawLocation) {
9
9
const result = { } ;
10
10
11
11
result . path = pathname ;
12
- result . search = mapValues ( qs . parse ( search ) , value => ( isNil ( value ) ? true : value ) ) ;
12
+ result . search = mapValues ( qs . parse ( search ) , ( value ) => ( isNil ( value ) ? true : value ) ) ;
13
13
result . hash = trimStart ( hash , "#" ) ;
14
14
result . url = `${ pathname } ${ search } ${ hash } ` ;
15
15
@@ -27,7 +27,7 @@ const location = {
27
27
28
28
confirmChange ( handler ) {
29
29
if ( isFunction ( handler ) ) {
30
- return history . block ( nextLocation => {
30
+ return history . block ( ( nextLocation ) => {
31
31
return handler ( normalizeLocation ( nextLocation ) , location ) ;
32
32
} ) ;
33
33
} else {
@@ -60,12 +60,18 @@ const location = {
60
60
// serialize search and keep existing search parameters (!)
61
61
if ( isObject ( newLocation . search ) ) {
62
62
newLocation . search = omitBy ( extend ( { } , location . search , newLocation . search ) , isNil ) ;
63
- newLocation . search = mapValues ( newLocation . search , value => ( value === true ? null : value ) ) ;
63
+ newLocation . search = mapValues ( newLocation . search , ( value ) => ( value === true ? null : value ) ) ;
64
64
newLocation . search = qs . stringify ( newLocation . search ) ;
65
65
}
66
66
}
67
67
if ( replace ) {
68
- history . replace ( newLocation ) ;
68
+ if (
69
+ newLocation . pathname !== location . path ||
70
+ newLocation . search !== qs . stringify ( location . search ) ||
71
+ newLocation . hash !== location . hash
72
+ ) {
73
+ history . replace ( newLocation ) ;
74
+ }
69
75
} else {
70
76
history . push ( newLocation ) ;
71
77
}
0 commit comments