diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-15 21:32:02 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-15 21:32:02 +0000 |
commit | 22120bccebc230657fa7e6481bb078ee9e6043dc (patch) | |
tree | f9692576c3405ee654d32669fc9976997051bc5c /lib | |
parent | f11eb9bbbab9fd46b24a1fa01d35bb680da56ae8 (diff) |
* Backport of r32559 from trunk
* lib/uri/common.rb (module): Remove optional parser argument to Kernel#URI
[ruby-core:38061]
* lib/uri/generic.rb (module): ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@32560 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/uri/common.rb | 18 | ||||
-rw-r--r-- | lib/uri/generic.rb | 6 |
2 files changed, 18 insertions, 6 deletions
diff --git a/lib/uri/common.rb b/lib/uri/common.rb index aaafeba478..92beafa8d8 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -233,7 +233,7 @@ module URI # Attempts to parse and merge a set of URIs # def join(*uris) - uris[0] = URI(uris[0], self) + uris[0] = convert_to_uri(uris[0]) uris.inject :merge end @@ -527,6 +527,18 @@ module URI ret end + + def convert_to_uri(uri) + if uri.is_a?(URI::Generic) + uri + elsif uri = String.try_convert(uri) + parse(uri) + else + raise ArgumentError, + "bad argument (expected URI object or URI string)" + end + end + end # class Parser # URI::Parser.new @@ -988,11 +1000,11 @@ module Kernel # # Returns +uri+ converted to a URI object. # - def URI(uri, parser = URI::DEFAULT_PARSER) + def URI(uri) if uri.is_a?(URI::Generic) uri elsif uri = String.try_convert(uri) - parser.parse(uri) + URI.parse(uri) else raise ArgumentError, "bad argument (expected URI object or URI string)" diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index a37649545a..1056cfe3bc 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -1239,7 +1239,7 @@ module URI # return base and rel. # you can modify `base', but can not `rel'. def merge0(oth) - oth = URI(oth, parser) + oth = parser.send(:convert_to_uri, oth) if self.relative? && oth.relative? raise BadURIError, @@ -1302,7 +1302,7 @@ module URI # :stopdoc: def route_from0(oth) - oth = URI(oth, parser) + oth = parser.send(:convert_to_uri, oth) if self.relative? raise BadURIError, "relative URI: #{self}" @@ -1410,7 +1410,7 @@ module URI # #=> #<URI::Generic:0x2020c2f6 URL:/main.rbx?page=1> # def route_to(oth) - URI(oth, parser).route_from(self) + parser.send(:convert_to_uri, oth).route_from(self) end # |