Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special character + is automatically removed from query string #2642

Closed
mrksbnch opened this Issue Mar 6, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@mrksbnch
Copy link

mrksbnch commented Mar 6, 2019

Version

3.0.2

Reproduction link

https://codesandbox.io/s/zkl0jwwk43

Steps to reproduce

Add a query string with the special character "+" to the URL in Codesandbox, e.g. add "?email=test+test@test.com" to the end of the URL: https://zkl0jwwk43.codesandbox.io/?email=test+test@test.com

What is expected?

I can access the query parameter "test" with this.$route.query.test to get the value "test+test@test.com".

What is actually happening?

When I try to get the value of the query parameter "test" I only get "test test@test.com" (space instead of "+").

@mrksbnch mrksbnch changed the title Special character is automatically removed Special character + is automatically removed from query string Mar 6, 2019

@posva

This comment has been minimized.

Copy link
Member

posva commented Mar 6, 2019

This is expected + produces spaces, you have to encode it with encodeURIComponent which yields %2B

@posva posva closed this Mar 6, 2019

@mrksbnch

This comment has been minimized.

Copy link
Author

mrksbnch commented Mar 6, 2019

@posva Thanks for checking. Does only "+" produce spaces or any other special character as well?

I'm also not sure why it's expected that "+" produces spaces. If I e.g. try to go to https://vuejs.org/?parameter=test+test@test.com and type window.location.search in the console, I get the expected string "?parameter=test+test@test.com" and not "?parameter=test test@test.com". Any reason why Vue Router behaves differently?

@posva

This comment has been minimized.

Copy link
Member

posva commented Mar 6, 2019

A bit long to explain but this does it pretty well: https://stackoverflow.com/questions/1211229/in-a-url-should-spaces-be-encoded-using-20-or

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.