summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS4
-rw-r--r--lib/uri/generic.rb6
-rw-r--r--test/uri/test_generic.rb6
3 files changed, 13 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index 12949c496c..b458b549a3 100644
--- a/NEWS
+++ b/NEWS
@@ -353,6 +353,10 @@ with all sufficient information, see the ChangeLog file or Redmine
* StringScanner#size, StringScanner#captures, StringScanner#values_at [Feature #836]
+* URI
+
+ * Relative path operations no longer collapse consecutive slashes to a single slash. [Bug #8352]
+
* WEBrick
* Add Server Name Indication (SNI) support [Feature #13729]
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb
index dc4f9c4c30..629323e80e 100644
--- a/lib/uri/generic.rb
+++ b/lib/uri/generic.rb
@@ -979,7 +979,7 @@ module URI
# returns an Array of the path split on '/'
#
def split_path(path)
- path.split(%r{/+}, -1)
+ path.split(%r{/}, -1)
end
private :split_path
@@ -1154,8 +1154,8 @@ module URI
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
diff --git a/test/uri/test_generic.rb b/test/uri/test_generic.rb
index b77717f949..7e428aa849 100644
--- a/test/uri/test_generic.rb
+++ b/test/uri/test_generic.rb
@@ -208,6 +208,9 @@ class URI::TestGeneric < Test::Unit::TestCase
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]")
@@ -265,6 +268,9 @@ class URI::TestGeneric < Test::Unit::TestCase
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')