@@ -12,12 +12,18 @@ export function createRoute (
12
12
router ?: VueRouter
13
13
) : Route {
14
14
const stringifyQuery = router && router . options . stringifyQuery
15
+
16
+ let query : any = location . query || { }
17
+ try {
18
+ query = clone ( query )
19
+ } catch ( e ) { }
20
+
15
21
const route : Route = {
16
22
name : location . name || ( record && record . name ) ,
17
23
meta : ( record && record . meta ) || { } ,
18
24
path : location . path || '/' ,
19
25
hash : location . hash || '' ,
20
- query : location . query || { } ,
26
+ query,
21
27
params : location . params || { } ,
22
28
fullPath : getFullPath ( location , stringifyQuery ) ,
23
29
matched : record ? formatMatch ( record ) : [ ]
@@ -28,6 +34,20 @@ export function createRoute (
28
34
return Object . freeze ( route )
29
35
}
30
36
37
+ function clone ( value ) {
38
+ if ( Array . isArray ( value ) ) {
39
+ return value . map ( clone )
40
+ } else if ( value && typeof value === 'object' ) {
41
+ const res = { }
42
+ for ( const key in value ) {
43
+ res [ key ] = clone ( value [ key ] )
44
+ }
45
+ return res
46
+ } else {
47
+ return value
48
+ }
49
+ }
50
+
31
51
// the starting route that represents the initial state
32
52
export const START = createRoute ( null , {
33
53
path : '/'
0 commit comments