Here is the problem: Ruby's URI library does not deal with umlauts; i.e.
irb> require "uri"
irb* URI("http://abc.de/äöü")
URI::InvalidURIError: bad URI(is not URI?): http://abc.de/äöü
How can I deal with that? This is Ruby 1.9.2, btw.
Call URI.encode before parsing:
require 'uri'
uri = URI(URI.encode("http://abc.de/äöü"))
As a side note, be aware that if the URL contains a hash fragment (#something), you'll have to manually split it:
require 'uri'
uri = URI(URI.encode('http://example.com/page.html') + '#' + URI.encode('anchor'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With