зеркало из https://github.com/github/ruby.git
uri/generic.rb: Tidy up merge
* lib/uri/generic.rb (URI::Generic#merge): merge merge0. [GH-1469] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
6ce158ba87
Коммит
587a24609b
|
@ -1,3 +1,8 @@
|
||||||
|
Mon Oct 31 11:08:51 2016 Samuel Williams <samuel.williams@oriontransfer.co.nz>
|
||||||
|
|
||||||
|
* lib/uri/generic.rb (URI::Generic#merge): merge merge0.
|
||||||
|
[GH-1469]
|
||||||
|
|
||||||
Sun Oct 30 15:32:43 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
Sun Oct 30 15:32:43 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
||||||
|
|
||||||
* lib/rubygems.rb, lib/rubygems/*, test/rubygems/*: Update
|
* lib/rubygems.rb, lib/rubygems/*, test/rubygems/*: Update
|
||||||
|
|
|
@ -1096,16 +1096,20 @@ module URI
|
||||||
# # => #<URI::HTTP:0x2021f3b0 URL:http://my.example.com/main.rbx?page=1>
|
# # => #<URI::HTTP:0x2021f3b0 URL:http://my.example.com/main.rbx?page=1>
|
||||||
#
|
#
|
||||||
def merge(oth)
|
def merge(oth)
|
||||||
begin
|
rel = parser.send(:convert_to_uri, oth)
|
||||||
base, rel = merge0(oth)
|
|
||||||
rescue
|
if rel.absolute?
|
||||||
raise $!.class, $!.message
|
#raise BadURIError, "both URI are absolute" if absolute?
|
||||||
|
# hmm... should return oth for usability?
|
||||||
|
return rel
|
||||||
end
|
end
|
||||||
|
|
||||||
if base == rel
|
unless self.absolute?
|
||||||
return base
|
raise BadURIError, "both URI are relative"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
base = self.dup
|
||||||
|
|
||||||
authority = rel.userinfo || rel.host || rel.port
|
authority = rel.userinfo || rel.host || rel.port
|
||||||
|
|
||||||
# RFC2396, Section 5.2, 2)
|
# RFC2396, Section 5.2, 2)
|
||||||
|
@ -1136,31 +1140,6 @@ module URI
|
||||||
end # merge
|
end # merge
|
||||||
alias + merge
|
alias + merge
|
||||||
|
|
||||||
# return base and rel.
|
|
||||||
# you can modify `base', but can not `rel'.
|
|
||||||
def merge0(oth)
|
|
||||||
oth = parser.send(:convert_to_uri, oth)
|
|
||||||
|
|
||||||
if self.relative? && oth.relative?
|
|
||||||
raise BadURIError,
|
|
||||||
"both URI are relative"
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.absolute? && oth.absolute?
|
|
||||||
#raise BadURIError,
|
|
||||||
# "both URI are absolute"
|
|
||||||
# hmm... should return oth for usability?
|
|
||||||
return oth, oth
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.absolute?
|
|
||||||
return self.dup, oth
|
|
||||||
else
|
|
||||||
return oth, oth
|
|
||||||
end
|
|
||||||
end
|
|
||||||
private :merge0
|
|
||||||
|
|
||||||
# :stopdoc:
|
# :stopdoc:
|
||||||
def route_from_path(src, dst)
|
def route_from_path(src, dst)
|
||||||
case dst
|
case dst
|
||||||
|
|
Загрузка…
Ссылка в новой задаче