How to encode a query string so that it is the value of another query string in javascript?

后端 未结 4 936
我在风中等你
我在风中等你 2020-12-28 13:15

I have a javascript function which passes as a query string value another query string.

In other words, I want the query string to be:

http://www.so         


        
4条回答
  •  再見小時候
    2020-12-28 13:29

    Native escape method does that. but also you can create a custom encoder like:

    function encodeUriSegment(val) {
      return encodeUriQuery(val, true).
                 replace(/%26/gi, '&').
                 replace(/%3D/gi, '=').
                 replace(/%2B/gi, '+');
    }
    

    this will replace keys used in query strings. further more you can apply it to any other custom encodings by adding needed key-values pairs.

提交回复
热议问题