为什么HTTP请求发送不正确?

时间:2015-05-15 12:05:55

标签: http url cross-browser uri

原始网址片段:{<>"|?(1)20416lol

编码的网址片段:

<code>encodeURIComponent('{<>"|?(1)20416lol')
-> %7B%3C%3E%22%7C%3F(1)20416lol</code>

但HTTP GET请求转到另一个URL。

screenshot

1 个答案:

答案 0 :(得分:0)

查看encodeURIComponent

上的moz dev网站

执行以下操作以覆盖默认的encodeURIComponent函数。

function fixedEncodeURIComponent (str) {
  return encodeURIComponent(str).replace(/[!'()*\|]/g, function(c) {
    return '%' + c.charCodeAt(0).toString(16);
  })
}