How to decode golang url.QueryEscape data in javascript?

I have a line in the JS side, which is url.QueryEscaped.

The spaces have been replaced by a + sign url.QueryEscape. They do not transform back into space decodeURIComponent. Do I have to manually make a line, replacing everything with a + space? What is the correct way to decode it?

+4
source share
1 answer

One simple method is to replace all characters with +spaces before decoding. For example:

decodeURIComponent("%2f+%2b".replace(/\+/g, " "))

will decode the string correctly before "/ +". Please note that replacement must be performed before decoding, as characters may be encoded in the string +.

+3

Source: https://habr.com/ru/post/1524833/


All Articles