Why doesn't decodeURI(“a+b”) == “a b”?

前端 未结 4 1480
执念已碎
执念已碎 2020-12-30 00:48

I\'m trying to encode URLs in Ruby and decode them with Javascript. However, the plus character is giving me weird behavior.

In Ruby:

[Dev]> CGI.e         


        
4条回答
  •  梦毁少年i
    2020-12-30 01:26

    From MDC decodeURI:

    Does not decode escape sequences that could not have been introduced by encodeURI.

    From MDC encodeURI:

    Note that encodeURI by itself cannot form proper HTTP GET and POST requests, such as for XMLHTTPRequests, because "&", "+", and "=" are not encoded

提交回复
热议问题