I think this would be most clear about the intent:

```
irb(main):010:0> uri = URI.parse(u)
=> #<URI::HTTPS:0x007f89ff8e94d8 URL:https://www.foo.com/a/b/c//d>
irb(main):011:0> uri.path = uri.path.gsub('//', '/')
=> "/a/b/c/d"
irb(main):012:0> uri.to_s
=> "https://www.foo.com/a/b/c/d"
```