-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
Reproduction
https://stackblitz.com/edit/vitejs-vite-qjvsopux
Steps to reproduce the bug
Description
When pushing a query using the vue-router, I've observed inconsistent encoding behavior: query parameters are either encoded twice or not at all.
Example
Consider the following code snippet:
const router = useRouter();
router.push({
query: { notEncoded: '{name}', encoded: encodeURIComponent('{name}') },
});The resulting URL appears as:
/?notEncoded={name}&encoded=%257Bname%257D
- The
notEncodedparameter remains unchanged, as expected. - The
encodedparameter, however, is encoded twice.
For reference, the expected single encoding result is:
console.log(encodeURIComponent('{name}')); // %7Bname%7DBut in the URL, it appears as %257Bname%257D, indicating double encoding.
Reproduction
You can reproduce this issue using the following Stackblitz project.
Expected behavior
/?notEncoded={name}&encoded=%7Bname%7D
Actual behavior
/?notEncoded={name}&encoded=%257Bname%257D
Additional information
No response
Metadata
Metadata
Assignees
Labels
No labels