你的缩短与多个&符号

时间:2014-05-09 08:56:21

标签: jquery ajax url-shortener yourls

我正在使用代理来缩短使用Yourls的url,代理调用jquery ajax方法(GET),传递了yourls-api.php的url参数

http://localhost/webapp/default.aspx?x=499833&y=244716&resolution=1&layer=image&cc=uk

但是,Yourls API忽略了来自第二个&符号的查询字符串,即缩短的url正在重定向

http://localhost/webapp/default.aspx?x=499833

longurl在传递代理之前被编码。

1 个答案:

答案 0 :(得分:1)

而不是编码完整的查询字符串,只编码url参数的值来修复问题。

原创

http://rishi.kb/yourls-api.php?signature=123456&action=shorturl&format=json&url=http://localhost/webapp/default.aspx?x=499833&y=244716&resolution=1&layer=image&cc=uk
老了:     http://rishi.kb/yourls-api.php?signature%3D123456%26action%3Dshorturl%26format%3Djson%26url%3Dhttp%3A%2F%2Flocalhost%2Fwebapp%2Fdefault.aspx%3Fx%3D499833%26y%3D244716%26resolution%3D1%26layer%3Dimage%26cc%3Duk

新:     http://rishi.kb/yourls-api.php?signature=123456&action=shorturl&format=json&url=http%3A%2F%2Flocalhost%2Fwebapp%2Fdefault.aspx%3Fx%3D499833%26y%3D244716%26resolution%3D1%26layer%3Dimage%26cc%3Duk