From 726e2f89ea3ede0393e2be16c5630a0751de30d1 Mon Sep 17 00:00:00 2001 From: Akinori MUSHA Date: Wed, 3 Apr 2013 18:41:22 +0900 Subject: [PATCH] Emulate behavior of URI() of ruby >=1.9 where it raises ArgumentError. --- lib/http/cookie.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/http/cookie.rb b/lib/http/cookie.rb index 6aeffed..f44f59e 100644 --- a/lib/http/cookie.rb +++ b/lib/http/cookie.rb @@ -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