Reputation: 167
how to remove a double slash //
in ruby with URI method?
2.4.1 :001 > URI('http://www.rbc.ru/society/23/11/2017/5a16ff0e9a7947e46d1e4957').tap { |uri| uri.query = nil; uri.scheme = nil }.to_s
=> "//www.rbc.ru/society/23/11/2017/5a16ff0e9a7947e46d1e4957"
Upvotes: 1
Views: 278
Reputation: 211560
Just snip it off:
URI('...').to_s.sub(%r[\A//], '')
Doesn't have to be that complicated.
Upvotes: 3