mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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/trunk@32559 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e05e992843
commit
c2dfaa7d40
3 changed files with 26 additions and 6 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Sat Jul 16 06:27:51 2011 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||||
|
|
||||||
|
* lib/uri/common.rb (module): Remove optional parser argument to
|
||||||
|
Kernel#URI
|
||||||
|
[ruby-core:38061]
|
||||||
|
|
||||||
|
* lib/uri/generic.rb (module): ditto
|
||||||
|
|
||||||
Sat Jul 16 03:19:45 2011 NAKAMURA Usaku <usa@ruby-lang.org>
|
Sat Jul 16 03:19:45 2011 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* win32/win32.c (is_socket, is_console): add prototypes to fix compile
|
* win32/win32.c (is_socket, is_console): add prototypes to fix compile
|
||||||
|
|
|
@ -233,7 +233,7 @@ module URI
|
||||||
# Attempts to parse and merge a set of URIs
|
# Attempts to parse and merge a set of URIs
|
||||||
#
|
#
|
||||||
def join(*uris)
|
def join(*uris)
|
||||||
uris[0] = URI(uris[0], self)
|
uris[0] = convert_to_uri(uris[0])
|
||||||
uris.inject :merge
|
uris.inject :merge
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -527,6 +527,18 @@ module URI
|
||||||
|
|
||||||
ret
|
ret
|
||||||
end
|
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
|
end # class Parser
|
||||||
|
|
||||||
# URI::Parser.new
|
# URI::Parser.new
|
||||||
|
@ -988,11 +1000,11 @@ module Kernel
|
||||||
#
|
#
|
||||||
# Returns +uri+ converted to a URI object.
|
# Returns +uri+ converted to a URI object.
|
||||||
#
|
#
|
||||||
def URI(uri, parser = URI::DEFAULT_PARSER)
|
def URI(uri)
|
||||||
if uri.is_a?(URI::Generic)
|
if uri.is_a?(URI::Generic)
|
||||||
uri
|
uri
|
||||||
elsif uri = String.try_convert(uri)
|
elsif uri = String.try_convert(uri)
|
||||||
parser.parse(uri)
|
URI.parse(uri)
|
||||||
else
|
else
|
||||||
raise ArgumentError,
|
raise ArgumentError,
|
||||||
"bad argument (expected URI object or URI string)"
|
"bad argument (expected URI object or URI string)"
|
||||||
|
|
|
@ -1239,7 +1239,7 @@ module URI
|
||||||
# return base and rel.
|
# return base and rel.
|
||||||
# you can modify `base', but can not `rel'.
|
# you can modify `base', but can not `rel'.
|
||||||
def merge0(oth)
|
def merge0(oth)
|
||||||
oth = URI(oth, parser)
|
oth = parser.send(:convert_to_uri, oth)
|
||||||
|
|
||||||
if self.relative? && oth.relative?
|
if self.relative? && oth.relative?
|
||||||
raise BadURIError,
|
raise BadURIError,
|
||||||
|
@ -1302,7 +1302,7 @@ module URI
|
||||||
|
|
||||||
# :stopdoc:
|
# :stopdoc:
|
||||||
def route_from0(oth)
|
def route_from0(oth)
|
||||||
oth = URI(oth, parser)
|
oth = parser.send(:convert_to_uri, oth)
|
||||||
if self.relative?
|
if self.relative?
|
||||||
raise BadURIError,
|
raise BadURIError,
|
||||||
"relative URI: #{self}"
|
"relative URI: #{self}"
|
||||||
|
@ -1410,7 +1410,7 @@ module URI
|
||||||
# #=> #<URI::Generic:0x2020c2f6 URL:/main.rbx?page=1>
|
# #=> #<URI::Generic:0x2020c2f6 URL:/main.rbx?page=1>
|
||||||
#
|
#
|
||||||
def route_to(oth)
|
def route_to(oth)
|
||||||
URI(oth, parser).route_from(self)
|
parser.send(:convert_to_uri, oth).route_from(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue