mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/uri/common.rb: Have URI#route_to, URI#route_from accept
string-like arguments [ruby-core:30961] * lib/uri/generic.rb: ditto for URI.join, URI#merge git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c618db17ee
commit
5647b2cd88
3 changed files with 14 additions and 36 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Wed Jul 21 13:37:35 2010 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||||
|
|
||||||
|
* lib/uri/common.rb: Have URI#route_to, URI#route_from accept
|
||||||
|
string-like arguments [ruby-core:30961]
|
||||||
|
|
||||||
|
* lib/uri/generic.rb: ditto for URI.join, URI#merge
|
||||||
|
|
||||||
Wed Jul 21 12:39:15 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
Wed Jul 21 12:39:15 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
* lib/cmath.rb (CMath#cbrt): cbrt should accept a negative real
|
* lib/cmath.rb (CMath#cbrt): cbrt should accept a negative real
|
||||||
|
|
|
@ -185,13 +185,7 @@ module URI
|
||||||
end
|
end
|
||||||
|
|
||||||
def join(*uris)
|
def join(*uris)
|
||||||
if uris[0].is_a?(URI::Generic)
|
uris[0] = URI(uris[0], self)
|
||||||
elsif uri = String.try_convert(uris[0])
|
|
||||||
uris[0] = self.parse(uri)
|
|
||||||
else
|
|
||||||
raise ArgumentError,
|
|
||||||
"bad argument(expected URI object or URI string)"
|
|
||||||
end
|
|
||||||
uris.inject :merge
|
uris.inject :merge
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -844,11 +838,11 @@ module Kernel
|
||||||
#
|
#
|
||||||
# Returns +uri+ converted to a URI object.
|
# Returns +uri+ converted to a URI object.
|
||||||
#
|
#
|
||||||
def URI(uri)
|
def URI(uri, parser = URI::DEFAULT_PARSER)
|
||||||
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)
|
||||||
URI.parse(uri)
|
parser.parse(uri)
|
||||||
else
|
else
|
||||||
raise ArgumentError,
|
raise ArgumentError,
|
||||||
"bad argument (expected URI object or URI string)"
|
"bad argument (expected URI object or URI string)"
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
#
|
#
|
||||||
# = uri/generic.rb
|
# = uri/generic.rb
|
||||||
#
|
#
|
||||||
|
@ -783,14 +784,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)
|
||||||
case oth
|
oth = URI(oth, parser)
|
||||||
when Generic
|
|
||||||
when String
|
|
||||||
oth = parser.parse(oth)
|
|
||||||
else
|
|
||||||
raise ArgumentError,
|
|
||||||
"bad argument(expected URI object or URI string)"
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.relative? && oth.relative?
|
if self.relative? && oth.relative?
|
||||||
raise BadURIError,
|
raise BadURIError,
|
||||||
|
@ -854,15 +848,7 @@ module URI
|
||||||
private :route_from_path
|
private :route_from_path
|
||||||
|
|
||||||
def route_from0(oth)
|
def route_from0(oth)
|
||||||
case oth
|
oth = URI(oth, parser)
|
||||||
when Generic
|
|
||||||
when String
|
|
||||||
oth = parser.parse(oth)
|
|
||||||
else
|
|
||||||
raise ArgumentError,
|
|
||||||
"bad argument(expected URI object or URI string)"
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.relative?
|
if self.relative?
|
||||||
raise BadURIError,
|
raise BadURIError,
|
||||||
"relative URI: #{self}"
|
"relative URI: #{self}"
|
||||||
|
@ -966,16 +952,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)
|
||||||
case oth
|
URI(oth, parser).route_from(self)
|
||||||
when Generic
|
|
||||||
when String
|
|
||||||
oth = parser.parse(oth)
|
|
||||||
else
|
|
||||||
raise ArgumentError,
|
|
||||||
"bad argument(expected URI object or URI string)"
|
|
||||||
end
|
|
||||||
|
|
||||||
oth.route_from(self)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue