D
D
Dmitry2018-03-17 17:27:51
JavaScript
Dmitry, 2018-03-17 17:27:51

Why does the browser replace + in a request with a space?

I send in the request (post and get behave the same)

PGEgY2xhc3M9Im5ld3NfdGl0bGVzIiBocmVmPSIiPtC+PC9hPg==

reaches the server
PGEgY2xhc3M9Im5ld3NfdGl0bGVzIiBocmVmPSIiPtC PC9hPg==


so I solved the problem by replacing + with %2B
but the reason is not clear because encodeURI + ignores

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2018-03-17
@demon416nds

encodeURI ignores + because it is a valid URI character used to pass a space.
Use encodeURIComponent .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question