Skip to content

Commit

Permalink
fix(query): do not normalize query with custom stringifyQuery
Browse files Browse the repository at this point in the history
Fix #328
  • Loading branch information
posva committed Jun 25, 2020
1 parent 6e1f0ea commit ea65066
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
normalizeQuery,
parseQuery as originalParseQuery,
stringifyQuery as originalStringifyQuery,
LocationQuery,
} from './query'
import {
shallowRef,
Expand Down Expand Up @@ -340,7 +341,15 @@ export function createRouter(options: RouterOptions): Router {
// keep the hash encoded so fullPath is effectively path + encodedQuery +
// hash
hash,
query: normalizeQuery(rawLocation.query),
query:
// if the user is using a custom query lib like qs, we might have
// nested objects, so we keep the query as is, meaning it can contain
// numbers at `$route.query`, but at the point, the user will have to
// use their own type anyway.
// https://github.com/vuejs/vue-router-next/issues/328#issuecomment-649481567
stringifyQuery === originalStringifyQuery
? normalizeQuery(rawLocation.query)
: (rawLocation.query as LocationQuery),
},
matchedRoute,
{
Expand Down Expand Up @@ -396,7 +405,7 @@ export function createRouter(options: RouterOptions): Router {
2
)}\n when navigating to "${
targetLocation.fullPath
}". A redirect must contain a name or path.`
}". A redirect must contain a name or path. This will break in production.`
)
return Promise.reject(new Error('Invalid redirect'))
}
Expand Down

0 comments on commit ea65066

Please sign in to comment.