Nobuyoshi Nakada
5/18/2007 5:30:00 PM
Hi,
At Sat, 19 May 2007 00:52:37 +0900,
Daniel Martin wrote in [ruby-talk:252116]:
> You know what? I'm using an old RFC. Everything I said applies to
> RFC 2396, but that's not the current URI RFC. The current one is
> RFC 3986, and by that one firefox is doing exactly the right thing.
> (So, by the way, is Opera)
>
> So it is a bug in URI, and the bug is "written to an old RFC".
Then, the test is wrong too?
Index: lib/uri/generic.rb
===================================================================
--- lib/uri/generic.rb (revision 12297)
+++ lib/uri/generic.rb (working copy)
@@ -632,9 +632,4 @@ module URI
base_path.slice!(i - 1, 2)
end
- if base_path.empty?
- base_path = [''] # keep '/' for root directory
- else
- base_path.pop
- end
# RFC2396, Section 5.2, 6), c)
@@ -654,5 +649,10 @@ module URI
end
- add_trailer_slash = true
+ add_trailer_slash = !tmp.empty?
+ if base_path.empty?
+ base_path = [''] # keep '/' for root directory
+ elsif add_trailer_slash
+ base_path.pop
+ end
while x = tmp.shift
if x == '..' && base_path.size > 1
Index: test/uri/test_generic.rb
===================================================================
--- test/uri/test_generic.rb (revision 12297)
+++ test/uri/test_generic.rb (working copy)
@@ -297,9 +297,9 @@ class TestGeneric < Test::Unit::TestCase
# http://a/b/c/d;p?q
-# ?y = http://a/b/c/?y
+# ?y = http://a/b/c/d;p?y
url = @base_url.merge('?y')
assert_kind_of(URI::HTTP, url)
- assert_equal('http://a/b/c/?y', url.to_s)
- url = @base_url.route_to('http://a/b/c/?y')
+ assert_equal('http://a/b/c/d;p?y', url.to_s)
+ url = @base_url.route_to('http://a/b/c/d;p?y')
assert_kind_of(URI::Generic, url)
assert_equal('?y', url.to_s)
--
Nobu Nakada