Calling router.replace('/#some%20hash') will lead to the fullPath/#some%2520hash. On the other hand, calling router.push('/#some%20hash') yields the original /#some%20hash.
Expected behavior
router.replace should behave like router.push and not re-encode the hash.
Actual behavior
router.replace re-encodes the hash for the fullPath resulting in a double encoding.
Additional information
This is particularly troublesome if you cannot use route.hash and have to rely on fullPath to extract the original value. For example, if the hash contains a mixture of search params encoding and URI encoding.
As a workaround: router.push({ path: '/', hash: '#some hash', replace: true }).
The fix for this one should be quite simple: the hash is not being decoded before transforming the replace into a push
Reproduction
https://jsfiddle.net/10q87pvg/
Steps to reproduce the bug
Calling
router.replace('/#some%20hash')
will lead to thefullPath
/#some%2520hash
. On the other hand, callingrouter.push('/#some%20hash')
yields the original/#some%20hash
.Expected behavior
router.replace
should behave likerouter.push
and not re-encode the hash.Actual behavior
router.replace
re-encodes the hash for thefullPath
resulting in a double encoding.Additional information
This is particularly troublesome if you cannot use
route.hash
and have to rely onfullPath
to extract the original value. For example, if the hash contains a mixture of search params encoding and URI encoding.