What is the use of encodeURIComponent for string encoding?

what I often see is that the parameters of the uri of the search page are encoded. Why should I encode the parameters? For example, the parameter is Xiaoming, can"t you search Xiaoming directly?

Aug.01,2021

http is a plaintext transmission and is not secure in itself. If you don't encode it, it is irresponsible to expose sensitive information on the address bar. So code delivery is very critical. In addition, most of them are https http protocols now.


there are two main reasons for string encoding. The first is security, which can effectively prevent some xss attacks, and the second is to enable the background to receive correct user input!

Menu