不要在查询字符串 stringify 中编码 url [英] Don't encode urls in querystring stringify

查看:52
本文介绍了不要在查询字符串 stringify 中编码 url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

qs.stringify 是否有任何选项可以对网址进行编码?

Is there any option for qs.stringify that will not encode the urls?

$ node
> var qs = require("querystring");
undefined
> qs.stringify({"url": "http://domain.com"});
'url=http%3A%2F%2Fdomain.com'

我想要以下输出:

'url=http://domain.com'

推荐答案

不是直接的,不是.虽然,如果您没有转义查询字符串中的值,那么使用查询字符串几乎没有任何好处.请记住:var q = 'url=http://domain.com'

Not directly, no. Although, if you are not escaping the value in the query string then there is hardly any benefit to using querystring at all. Mind as well just do: var q = 'url=http://domain.com'

从查看源代码来看,唯一的方法是更改​​(即覆盖)查询字符串转义()函数的行为 - 这是可能的,但不是一个好主意.

From looking at the source, the only way would be to change the behavior of (i.e. overwrite) the querystring escape() function - which is possible but not a good idea.

这篇关于不要在查询字符串 stringify 中编码 url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆