How to fix bad URI is not URI [duplicate]

Solution 1:

This url is not valid, but it works in browser because browser itself is less strict about special characters like :, /, etc.

You should encode your URI first

encoded_url = URI.encode(url)

And then parse it

URI.parse(encoded_url)

Solution 2:

Addressable::URI is a better, more rfc-compliant replacement for URI:

require "addressable/uri"
Addressable::URI.parse(url).host
#=> "ferrari-view.4me.it"

gem install addressable first.