1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Append "//" if empty host for file or postgres URI

https://url.spec.whatwg.org/#url-serializing
> Otherwise, if url’s host is null and url’s scheme is "file", append "//" to output.

URL spec doesn't says anything about postgres, but assume the same thing.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2017-12-01 15:09:41 +00:00
parent 51716c331f
commit ed48bfa5e8
2 changed files with 5 additions and 1 deletions

View file

@ -1341,7 +1341,7 @@ module URI
if @opaque
str << @opaque
else
if @host
if @host || %w[file postgres].include?(@scheme)
str << '//'
end
if self.userinfo

View file

@ -20,6 +20,10 @@ class URI::TestGeneric < Test::Unit::TestCase
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