Project

General

Profile

Bug #8352 ยป 0001-Allow-empty-path-components-in-a-URI-Bug-8352.patch

knu (Akinori MUSHA), 12/12/2017 05:45 AM

View differences:

lib/uri/generic.rb
# returns an Array of the path split on '/'
#
def split_path(path)
path.split(%r{/+}, -1)
path.split(%r{/}, -1)
end
private :split_path
......
return dst.dup
end
src_path = src.scan(%r{(?:\A|[^/]+)/})
dst_path = dst.scan(%r{(?:\A|[^/]+)/?})
src_path = src.scan(%r{[^/]*/})
dst_path = dst.scan(%r{[^/]*/?})
# discard same parts
while !dst_path.empty? && dst_path.first == src_path.first
test/uri/test_generic.rb
assert(nil != u.merge!("../baz"))
assert_equal('http://foo/baz', u.to_s)
url = URI.parse('http://a/b//c') + 'd//e'
assert_equal('http://a/b//d//e', url.to_s)
u0 = URI.parse('mailto:foo@example.com')
u1 = URI.parse('mailto:foo@example.com#bar')
assert_equal(uri_to_ary(u0 + '#bar'), uri_to_ary(u1), "[ruby-dev:23628]")
......
url = URI.parse('http://hoge/b').route_to('http://hoge/b:c')
assert_equal('./b:c', url.to_s)
url = URI.parse('http://hoge/b//c').route_to('http://hoge/b/c')
assert_equal('../c', url.to_s)
url = URI.parse('file:///a/b/').route_to('file:///a/b/')
assert_equal('', url.to_s)
url = URI.parse('file:///a/b/').route_to('file:///a/b')
    (1-1/1)