]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
fix: encode hash
authorEduardo San Martin Morote <posva13@gmail.com>
Tue, 28 Apr 2020 15:08:49 +0000 (17:08 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Tue, 28 Apr 2020 15:08:49 +0000 (17:08 +0200)
src/router.ts

index 26dd3cc7f7702a4d68f286d1c18da881ce55971f..7544fd53cd248e55da6a752436ce159a793de475 100644 (file)
@@ -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,