require \'uri\'
uri = URI.parse \'http://dxczjjuegupb.cloudfront.net/wp-content/uploads/2017/10/Оуэн-Мэтьюс.jpg\'
The browsers have no problem with
What do you think about:
url = URI.escape(url) unless url.ascii_only?
URI.parse(url)
The answer just came to me by asking myself the question:
begin
uri = URI.parse(url)
rescue URI::InvalidURIError
uri = URI.parse(URI.escape(url))
end
I had the same error:
Ruby: URI::InvalidURIError (URI must be ascii only
with my code, but my bug was that it was an old project and the i18n was outdated. It was solved, with a simple:
bundle update