[前][次][番号順一覧][スレッド一覧]

ruby-changes:44456

From: nobu <ko1@a...>
Date: Mon, 31 Oct 2016 11:09:02 +0900 (JST)
Subject: [ruby-changes:44456] nobu:r56528 (trunk): uri/generic.rb: Tidy up merge

nobu	2016-10-31 11:08:54 +0900 (Mon, 31 Oct 2016)

  New Revision: 56528

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56528

  Log:
    uri/generic.rb: Tidy up merge
    
    * lib/uri/generic.rb (URI::Generic#merge): merge merge0.
      [GH-1469]

  Modified files:
    trunk/ChangeLog
    trunk/lib/uri/generic.rb
Index: lib/uri/generic.rb
===================================================================
--- lib/uri/generic.rb	(revision 56527)
+++ lib/uri/generic.rb	(revision 56528)
@@ -1096,16 +1096,20 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/generic.rb#L1096
     #   # =>  #<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 https://github.com/ruby/ruby/blob/trunk/lib/uri/generic.rb#L1140
     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
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 56527)
+++ ChangeLog	(revision 56528)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Oct 31 11:08:51 2016  Samuel Williams  <samuel.williams@o...>
+
+	* lib/uri/generic.rb (URI::Generic#merge): merge merge0.
+	  [GH-1469]
+
 Sun Oct 30 15:32:43 2016  SHIBATA Hiroshi  <hsbt@r...>
 
 	* lib/rubygems.rb, lib/rubygems/*, test/rubygems/*: Update

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]