开发者

Ruby - clean up url

Is there a quick way to clean up a url that is malformed with a 2nd question mark instead of ampersand? i.e.

http://google.com?x=1?y=2

thx开发者_运维技巧


'http://google.com?x=1?y=2'.split('?',2).map{|i| i.gsub('?', '&')}.join('?')
#=> "http://google.com?x=1&y=2"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜