diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-10-31 02:08:54 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-10-31 02:08:54 +0000 |
commit | 587a24609bea4d7587510f614ac47fa56e7b246a (patch) | |
tree | 56cf912bfb3593cfcd0b4fe18537dc3720056bf9 /lib/uri | |
parent | 6ce158ba870eb815ba9775ac8380b32fd81be040 (diff) | |
download | ruby-587a24609bea4d7587510f614ac47fa56e7b246a.tar.gz |
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
Diffstat (limited to 'lib/uri')
-rw-r--r-- | lib/uri/generic.rb | 41 |
1 files changed, 10 insertions, 31 deletions
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index 2b95b47fa7..5df9a163fe 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -1096,16 +1096,20 @@ module URI # # => #<URI::HTTP:0x2021f3b0 URL:http://my.example.com/main.rbx?page=1> # def merge(oth) - begin - base, rel = merge0(oth) - rescue - raise $!.class, $!.message + rel = parser.send(:convert_to_uri, oth) + + if rel.absolute? + #raise BadURIError, "both URI are absolute" if absolute? + # hmm... should return oth for usability? + return rel end - if base == rel - return base + unless self.absolute? + raise BadURIError, "both URI are relative" end + base = self.dup + authority = rel.userinfo || rel.host || rel.port # RFC2396, Section 5.2, 2) @@ -1136,31 +1140,6 @@ module URI end # 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: def route_from_path(src, dst) case dst |