[#39804] CGIでのリダイレクションの書き方 — Yoichiro Takehora <yoichiro@...>
こんにちは、竹洞です。
7 messages
2004/07/02
[#39811] keyword-argument-like argument passing via Hash — NISHIMATSU Takeshi <t-nissie@...>
西松と申します.
4 messages
2004/07/02
[#39814] Socket:IPヘッダの編集方法 — takeshi honda <moecho21@...>
本田と申します。
6 messages
2004/07/02
[#39819] [ANN] Ruby-GetText-Package-0.6.0 — Masao Mutoh <mutoh@...>
むとうです。
4 messages
2004/07/04
[#39822] (要素がString, Fixnum 以外の)配列の集合演算 — Hiroshi Takagi <gollum@...>
高木といいます、よろしく。
11 messages
2004/07/05
[#39823] Re: (要素がString, Fixnum 以外の)配列の集合演算
— 卜部昌平 <s-urabe@...>
2004/07/05
mput です。
[#39824] Re: (要素がString, Fixnum 以外の)配列の集合演算
— Hiroshi Takagi <gollum@...>
2004/07/05
高木です。
[#39826] Re: (要素がString, Fixnum 以外の)配列の集合演算
— nobu.nakada@...
2004/07/06
なかだです。
[#39856] 直接関係のない配列の有無が、ある配列の値に影響する不具合 — "Hisashi Yahata" <yahatah@...>
5 messages
2004/07/17
[#39863] forループの速度 — Masahiro Sato <msato@...>
15 messages
2004/07/20
[#39868] イテレータとfor文 — OOTANI TAKASHI <otn@...5.so-net.ne.jp>
大谷と申します。
31 messages
2004/07/20
[#39870] Re: イテレータとfor文
— Nowake <nowake@...>
2004/07/20
[#39886] Re: イテレータとfor文
— Tietew <tietew-ml-ruby-list@...>
2004/07/21
[#39891] Re: イテレータとfor文
— OOTANI TAKASHI <otn@...5.so-net.ne.jp>
2004/07/21
大谷です。
[#39910] Re: イテレータとfor文
— Atoh <atoh@...7.jp>
2004/07/23
あとうです。
[#39911] Re: イテレータとfor文
— OOTANI TAKASHI <otn@...5.so-net.ne.jp>
2004/07/23
大谷です。
[#39889] dRuby: 急に遅くなる — ちば けいすけ <chowder@...>
ちばです。
7 messages
2004/07/21
[#39908] htreeの高速化 — MoonWolf <moonwolf@...>
MoonWolfです。
6 messages
2004/07/23
[ruby-list:39840] Re: URI#merge and relative references
From:
akira yamada / やまだあきら <akira@...>
Date:
2004-07-07 14:58:41 UTC
List:
ruby-list #39840
>>>>> In [ruby-list : No.39838]
>>>>> sheepman <sheepman@tcn.zaq.ne.jp> wrote:
> URI ライブラリで、
> p URI.parse("http://www.example.com/foo/..") + "./"
> => #<URI::HTTP:0x2010db84 URL:http://www.example.com/foo/>
> となります。この
> http://www.example.com/foo/
> は
> http://www.example.com/
> となるべきなのではないでしょうか。
こんな感じでどうでしょうか。
--- lib/uri/generic.rb 9 Jun 2004 09:05:41 -0000 1.13.2.2
+++ lib/uri/generic.rb 7 Jul 2004 14:57:14 -0000
@@ -630,15 +630,19 @@
base_path = split_path(base)
rel_path = split_path(rel)
- if base_path.empty?
- base_path = [''] # XXX
- end
-
# RFC2396, Section 5.2, 6), a)
- base_path.pop unless base_path.size == 1
+ base_path << '' if base_path.last == '..'
+ while i = base_path.index('..')
+ 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)
- # RFC2396, Section 5.2, 6), d)
+ # RFC2396, Section 5.2, 6), d)
rel_path.push('') if rel_path.last == '.'
rel_path.delete('.')
テストはこんな感じで足りてますでしょうか。
--- test/uri/test_generic.rb 9 Jun 2004 09:05:41 -0000 1.5.2.1
+++ test/uri/test_generic.rb 7 Jul 2004 14:57:14 -0000
@@ -163,6 +163,23 @@
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-list:39838]
+ u0 = URI.parse('http://www.example.com/')
+ u1 = URI.parse('http://www.example.com/foo/..') + './'
+ assert_equal(u0, u1)
+ u0 = URI.parse('http://www.example.com/foo/')
+ u1 = URI.parse('http://www.example.com/foo/bar/..') + './'
+ assert_equal(u0, u1)
+ u0 = URI.parse('http://www.example.com/foo/bar/')
+ u1 = URI.parse('http://www.example.com/foo/bar/baz/..') + './'
+ assert_equal(u0, u1)
+ u0 = URI.parse('http://www.example.com/')
+ u1 = URI.parse('http://www.example.com/foo/bar/../..') + './'
+ assert_equal(u0, u1)
+ u0 = URI.parse('http://www.example.com/foo/')
+ u1 = URI.parse('http://www.example.com/foo/bar/baz/../..') + './'
+ assert_equal(u0, u1)
end
def test_route
--
やまだあきら <URL:http://arika.org>
Vine Caves, Ltd. <URL:http://vinecaves.com>