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

ruby-changes:48853

From: naruse <ko1@a...>
Date: Sat, 2 Dec 2017 00:09:45 +0900 (JST)
Subject: [ruby-changes:48853] naruse:r60970 (trunk): Append "//" if empty host for file or postgres URI

naruse	2017-12-02 00:09:41 +0900 (Sat, 02 Dec 2017)

  New Revision: 60970

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

  Log:
    Append "//" if empty host for file or postgres URI
    
    https://url.spec.whatwg.org/#url-serializing
    > Otherwise, if url?\226?\128?\153s host is null and url?\226?\128?\153s scheme is "file", append "//" to output.
    
    URL spec doesn't says anything about postgres, but assume the same thing.

  Modified files:
    trunk/lib/uri/generic.rb
    trunk/test/uri/test_generic.rb
Index: test/uri/test_generic.rb
===================================================================
--- test/uri/test_generic.rb	(revision 60969)
+++ test/uri/test_generic.rb	(revision 60970)
@@ -20,6 +20,10 @@ class URI::TestGeneric < Test::Unit::Tes https://github.com/ruby/ruby/blob/trunk/test/uri/test_generic.rb#L20
     str = URI(exp).to_s
     assert_equal exp, str
     assert_not_predicate str, :frozen?, '[ruby-core:71785] [Bug #11759]'
+
+    assert_equal "file:///foo", URI("file:///foo").to_s
+    assert_equal "postgres:///foo", URI("postgres:///foo").to_s
+    assert_equal "http:/foo", URI("http:///foo").to_s
   end
 
   def test_parse
Index: lib/uri/generic.rb
===================================================================
--- lib/uri/generic.rb	(revision 60969)
+++ lib/uri/generic.rb	(revision 60970)
@@ -1341,7 +1341,7 @@ module URI https://github.com/ruby/ruby/blob/trunk/lib/uri/generic.rb#L1341
       if @opaque
         str << @opaque
       else
-        if @host
+        if @host || %w[file postgres].include?(@scheme)
           str << '//'
         end
         if self.userinfo

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

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