Emulate behavior of URI() of ruby >=1.9 where it raises ArgumentError.

This commit is contained in:
Akinori MUSHA 2013-04-03 18:41:22 +09:00
parent 9b4ce19873
commit 726e2f89ea

View file

@ -14,7 +14,14 @@ if RUBY_VERSION < "1.9.3"
URI(URI(''))
rescue
def URI(url) # :nodoc:
url.is_a?(URI) ? url : URI.parse(url)
case url
when URI
url
when String
URI.parse(url)
else
raise ArgumentError, 'bad argument (expected URI object or URI string)'
end
end
end
end