mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Merge uri-0.12.4
This commit is contained in:
parent
b97108a646
commit
ca7cc093c4
4 changed files with 28 additions and 9 deletions
|
@ -19,6 +19,8 @@ module URI
|
|||
Parser = RFC2396_Parser
|
||||
RFC3986_PARSER = RFC3986_Parser.new
|
||||
Ractor.make_shareable(RFC3986_PARSER) if defined?(Ractor)
|
||||
RFC2396_PARSER = RFC2396_Parser.new
|
||||
Ractor.make_shareable(RFC2396_PARSER) if defined?(Ractor)
|
||||
|
||||
# URI::Parser.new
|
||||
DEFAULT_PARSER = Parser.new
|
||||
|
|
|
@ -1133,17 +1133,16 @@ module URI
|
|||
base.fragment=(nil)
|
||||
|
||||
# RFC2396, Section 5.2, 4)
|
||||
if !authority
|
||||
base.set_path(merge_path(base.path, rel.path)) if base.path && rel.path
|
||||
else
|
||||
# RFC2396, Section 5.2, 4)
|
||||
base.set_path(rel.path) if rel.path
|
||||
if authority
|
||||
base.set_userinfo(rel.userinfo)
|
||||
base.set_host(rel.host)
|
||||
base.set_port(rel.port || base.default_port)
|
||||
base.set_path(rel.path)
|
||||
elsif base.path && rel.path
|
||||
base.set_path(merge_path(base.path, rel.path))
|
||||
end
|
||||
|
||||
# RFC2396, Section 5.2, 7)
|
||||
base.set_userinfo(rel.userinfo) if rel.userinfo
|
||||
base.set_host(rel.host) if rel.host
|
||||
base.set_port(rel.port) if rel.port
|
||||
base.query = rel.query if rel.query
|
||||
base.fragment=(rel.fragment) if rel.fragment
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module URI
|
||||
# :stopdoc:
|
||||
VERSION_CODE = '001202'.freeze
|
||||
VERSION_CODE = '001204'.freeze
|
||||
VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
|
||||
# :startdoc:
|
||||
end
|
||||
|
|
|
@ -164,6 +164,17 @@ class URI::TestGeneric < Test::Unit::TestCase
|
|||
# must be empty string to identify as path-abempty, not path-absolute
|
||||
assert_equal('', url.host)
|
||||
assert_equal('http:////example.com', url.to_s)
|
||||
|
||||
# sec-2957667
|
||||
url = URI.parse('http://user:pass@example.com').merge('//example.net')
|
||||
assert_equal('http://example.net', url.to_s)
|
||||
assert_nil(url.userinfo)
|
||||
url = URI.join('http://user:pass@example.com', '//example.net')
|
||||
assert_equal('http://example.net', url.to_s)
|
||||
assert_nil(url.userinfo)
|
||||
url = URI.parse('http://user:pass@example.com') + '//example.net'
|
||||
assert_equal('http://example.net', url.to_s)
|
||||
assert_nil(url.userinfo)
|
||||
end
|
||||
|
||||
def test_parse_scheme_with_symbols
|
||||
|
@ -256,6 +267,13 @@ class URI::TestGeneric < Test::Unit::TestCase
|
|||
assert_equal(u0, u1)
|
||||
end
|
||||
|
||||
def test_merge_authority
|
||||
u = URI.parse('http://user:pass@example.com:8080')
|
||||
u0 = URI.parse('http://new.example.org/path')
|
||||
u1 = u.merge('//new.example.org/path')
|
||||
assert_equal(u0, u1)
|
||||
end
|
||||
|
||||
def test_route
|
||||
url = URI.parse('http://hoge/a.html').route_to('http://hoge/b.html')
|
||||
assert_equal('b.html', url.to_s)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue