Merge URI-0.13.3

This commit is contained in:
Hiroshi SHIBATA 2025-10-07 18:28:32 +09:00 committed by nagachika
parent 4fb1eec1e3
commit 3fe7f490ff
3 changed files with 32 additions and 14 deletions

View File

@ -186,18 +186,18 @@ module URI
if arg_check
self.scheme = scheme
self.userinfo = userinfo
self.hostname = host
self.port = port
self.userinfo = userinfo
self.path = path
self.query = query
self.opaque = opaque
self.fragment = fragment
else
self.set_scheme(scheme)
self.set_userinfo(userinfo)
self.set_host(host)
self.set_port(port)
self.set_userinfo(userinfo)
self.set_path(path)
self.query = query
self.set_opaque(opaque)
@ -511,7 +511,7 @@ module URI
user, password = split_userinfo(user)
end
@user = user
@password = password if password
@password = password
[@user, @password]
end
@ -522,7 +522,7 @@ module URI
# See also URI::Generic.user=.
#
def set_user(v)
set_userinfo(v, @password)
set_userinfo(v, nil)
v
end
protected :set_user
@ -574,6 +574,12 @@ module URI
@password
end
# Returns the authority info (array of user, password, host and
# port), if any is set. Or returns +nil+.
def authority
return @user, @password, @host, @port if @user || @password || @host || @port
end
# Returns the user component after URI decoding.
def decoded_user
URI.decode_uri_component(@user) if @user
@ -615,6 +621,13 @@ module URI
end
protected :set_host
# Protected setter for the authority info (+user+, +password+, +host+
# and +port+). If +port+ is +nil+, +default_port+ will be set.
#
protected def set_authority(user, password, host, port = nil)
@user, @password, @host, @port = user, password, host, port || self.default_port
end
#
# == Args
#
@ -639,6 +652,7 @@ module URI
def host=(v)
check_host(v)
set_host(v)
set_userinfo(nil)
v
end
@ -729,6 +743,7 @@ module URI
def port=(v)
check_port(v)
set_port(v)
set_userinfo(nil)
port
end
@ -1121,7 +1136,7 @@ module URI
base = self.dup
authority = rel.userinfo || rel.host || rel.port
authority = rel.authority
# RFC2396, Section 5.2, 2)
if (rel.path.nil? || rel.path.empty?) && !authority && !rel.query
@ -1134,9 +1149,7 @@ module URI
# RFC2396, Section 5.2, 4)
if authority
base.set_userinfo(rel.userinfo)
base.set_host(rel.host)
base.set_port(rel.port || base.default_port)
base.set_authority(*authority)
base.set_path(rel.path)
elsif base.path && rel.path
base.set_path(merge_path(base.path, rel.path))

View File

@ -1,6 +1,6 @@
module URI
# :stopdoc:
VERSION_CODE = '001302'.freeze
VERSION_CODE = '001303'.freeze
VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
# :startdoc:
end

View File

@ -272,6 +272,9 @@ class URI::TestGeneric < Test::Unit::TestCase
u0 = URI.parse('http://new.example.org/path')
u1 = u.merge('//new.example.org/path')
assert_equal(u0, u1)
u0 = URI.parse('http://other@example.net')
u1 = u.merge('//other@example.net')
assert_equal(u0, u1)
end
def test_route
@ -737,17 +740,18 @@ class URI::TestGeneric < Test::Unit::TestCase
def test_set_component
uri = URI.parse('http://foo:bar@baz')
assert_equal('oof', uri.user = 'oof')
assert_equal('http://oof:bar@baz', uri.to_s)
assert_equal('http://oof@baz', uri.to_s)
assert_equal('rab', uri.password = 'rab')
assert_equal('http://oof:rab@baz', uri.to_s)
assert_equal('foo', uri.userinfo = 'foo')
assert_equal('http://foo:rab@baz', uri.to_s)
assert_equal('http://foo@baz', uri.to_s)
assert_equal(['foo', 'bar'], uri.userinfo = ['foo', 'bar'])
assert_equal('http://foo:bar@baz', uri.to_s)
assert_equal(['foo'], uri.userinfo = ['foo'])
assert_equal('http://foo:bar@baz', uri.to_s)
assert_equal('http://foo@baz', uri.to_s)
assert_equal('zab', uri.host = 'zab')
assert_equal('http://foo:bar@zab', uri.to_s)
assert_equal('http://zab', uri.to_s)
uri.userinfo = ['foo', 'bar']
uri.port = ""
assert_nil(uri.port)
uri.port = "80"
@ -757,7 +761,8 @@ class URI::TestGeneric < Test::Unit::TestCase
uri.port = " 080 "
assert_equal(80, uri.port)
assert_equal(8080, uri.port = 8080)
assert_equal('http://foo:bar@zab:8080', uri.to_s)
assert_equal('http://zab:8080', uri.to_s)
uri = URI.parse('http://foo:bar@zab:8080')
assert_equal('/', uri.path = '/')
assert_equal('http://foo:bar@zab:8080/', uri.to_s)
assert_equal('a=1', uri.query = 'a=1')