From 85bb7e11b1a4326f5048a823ae7d49654b308cdd Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Tue, 28 Apr 2020 17:08:49 +0200 Subject: [PATCH] fix: encode hash --- src/router.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/router.ts b/src/router.ts index 26dd3cc7..7544fd53 100644 --- a/src/router.ts +++ b/src/router.ts @@ -33,7 +33,7 @@ import { } from './errors' import { applyToParams, isBrowser } from './utils' import { useCallbacks } from './utils/callbacks' -import { encodeParam, decode } from './encoding' +import { encodeParam, decode, encodeHash } from './encoding' import { normalizeQuery, parseQuery as originalParseQuery, @@ -244,6 +244,8 @@ export function createRouter({ currentLocation ) + const hash = encodeHash(location.hash || '') + // put back the unencoded params as given by the user (avoid the cost of decoding them) // TODO: normalize params if we accept numbers as raw values matchedRoute.params = @@ -253,12 +255,15 @@ export function createRouter({ const fullPath = stringifyURL(stringifyQuery, { ...location, + hash, path: matchedRoute.path, }) return { fullPath, - hash: location.hash || '', + // keep the hash encoded so fullPath is effectively path + encodedQuery + + // hash + hash, query: normalizeQuery(location.query), ...matchedRoute, redirectedFrom: undefined, -- 2.47.2