@@ -12,12 +12,18 @@ export function createRoute (
1212 router ?: VueRouter
1313) : Route {
1414 const stringifyQuery = router && router . options . stringifyQuery
15+
16+ let query : any = location . query || { }
17+ try {
18+ query = clone ( query )
19+ } catch ( e ) { }
20+
1521 const route : Route = {
1622 name : location . name || ( record && record . name ) ,
1723 meta : ( record && record . meta ) || { } ,
1824 path : location . path || '/' ,
1925 hash : location . hash || '' ,
20- query : location . query || { } ,
26+ query,
2127 params : location . params || { } ,
2228 fullPath : getFullPath ( location , stringifyQuery ) ,
2329 matched : record ? formatMatch ( record ) : [ ]
@@ -28,6 +34,20 @@ export function createRoute (
2834 return Object . freeze ( route )
2935}
3036
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+
3151// the starting route that represents the initial state
3252export const START = createRoute ( null , {
3353 path : '/'
0 commit comments