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
979 979
    # returns an Array of the path split on '/'
980 980
    #
981 981
    def split_path(path)
982
      path.split(%r{/+}, -1)
982
      path.split(%r{/}, -1)
983 983
    end
984 984
    private :split_path
985 985

  
......
1154 1154
        return dst.dup
1155 1155
      end
1156 1156

  
1157
      src_path = src.scan(%r{(?:\A|[^/]+)/})
1158
      dst_path = dst.scan(%r{(?:\A|[^/]+)/?})
1157
      src_path = src.scan(%r{[^/]*/})
1158
      dst_path = dst.scan(%r{[^/]*/?})
1159 1159

  
1160 1160
      # discard same parts
1161 1161
      while !dst_path.empty? && dst_path.first == src_path.first
test/uri/test_generic.rb
208 208
    assert(nil != u.merge!("../baz"))
209 209
    assert_equal('http://foo/baz', u.to_s)
210 210

  
211
    url = URI.parse('http://a/b//c') + 'd//e'
212
    assert_equal('http://a/b//d//e', url.to_s)
213

  
211 214
    u0 = URI.parse('mailto:foo@example.com')
212 215
    u1 = URI.parse('mailto:foo@example.com#bar')
213 216
    assert_equal(uri_to_ary(u0 + '#bar'), uri_to_ary(u1), "[ruby-dev:23628]")
......
265 268
    url = URI.parse('http://hoge/b').route_to('http://hoge/b:c')
266 269
    assert_equal('./b:c', url.to_s)
267 270

  
271
    url = URI.parse('http://hoge/b//c').route_to('http://hoge/b/c')
272
    assert_equal('../c', url.to_s)
273

  
268 274
    url = URI.parse('file:///a/b/').route_to('file:///a/b/')
269 275
    assert_equal('', url.to_s)
270 276
    url = URI.parse('file:///a/b/').route_to('file:///a/b')
271
-