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"
精彩评论