Skip to content

Commit

Permalink
fix: avoid normalizing the fullPath
Browse files Browse the repository at this point in the history
Close #2187
  • Loading branch information
posva committed Mar 25, 2024
1 parent 31c5936 commit e4805e6
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions packages/router/src/router.ts
Expand Up @@ -525,13 +525,19 @@ export function createRouter(options: RouterOptions): Router {
// we need to run the decoding again
matchedRoute.params = normalizeParams(decodeParams(matchedRoute.params))

const fullPath = stringifyURL(
stringifyQuery,
assign({}, rawLocation, {
hash: encodeHash(hash),
path: matchedRoute.path,
})
)
const fullPath =
// @ts-expect-error: the rawLocation doesn't normally have a fullPath
// but sometimes it gets noramlized before being passed to resolve and we can
// resue it to avoid encoding an unencoded path from the user in order to be closer
// to the URL constructor behavior. vuejs/router#2187
rawLocation.fullPath ||
stringifyURL(
stringifyQuery,
assign({}, rawLocation, {
hash: encodeHash(hash),
path: matchedRoute.path,
})
)

const href = routerHistory.createHref(fullPath)
if (__DEV__) {
Expand Down

0 comments on commit e4805e6

Please sign in to comment.