From: Eduardo San Martin Morote Date: Tue, 28 Apr 2020 15:08:49 +0000 (+0200) Subject: fix: encode hash X-Git-Tag: v4.0.0-alpha.8~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85bb7e11b1a4326f5048a823ae7d49654b308cdd;p=thirdparty%2Fvuejs%2Frouter.git fix: encode hash --- 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,