开发者

Ruby - clean up url

开发者 https://www.devze.com 2022-12-19 21:15 出处:网络
Is there a quick way to clean up a url that is malformed with a 2nd question mark instead of ampersand? i.e.

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

精彩评论

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