diff options
author | akira <akira@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-07-13 10:50:26 +0000 |
---|---|---|
committer | akira <akira@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-07-13 10:50:26 +0000 |
commit | 35ef4bab8e147b66f64e2cf38666e59ac4090b80 (patch) | |
tree | 83c021061d6f926ff02185efcbde71827753da9a /lib/uri | |
parent | 4e11d565d3b2e3caad1e791be78e60ee76613401 (diff) | |
download | ruby-35ef4bab8e147b66f64e2cf38666e59ac4090b80.tar.gz |
* lib/uri/generic.rb (URI::Generic#merge_path):
"URI('http://www.example.com/foo/..') + './'" should return
"URI('http://www.example.com/')". [ruby-list:39838]
"URI('http://www.example.com/') + './foo/bar/..'" should return
"URI('http://www.example.com/foo/')". [ruby-list:39844]
* test/uri/test_generic.rb (TestGeneric#test_merge): added tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/uri')
-rw-r--r-- | lib/uri/generic.rb | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb index 3d6cc8525b..0dedcf494a 100644 --- a/lib/uri/generic.rb +++ b/lib/uri/generic.rb @@ -630,16 +630,20 @@ module URI base_path = split_path(base) rel_path = split_path(rel) + # RFC2396, Section 5.2, 6), a) + base_path << '' if base_path.last == '..' + while i = base_path.index('..') + base_path.slice!(i - 1, 2) + end if base_path.empty? - base_path = [''] # XXX + base_path = [''] # keep '/' for root directory + else + base_path.pop end - # RFC2396, Section 5.2, 6), a) - base_path.pop unless base_path.size == 1 - # RFC2396, Section 5.2, 6), c) - # RFC2396, Section 5.2, 6), d) - rel_path.push('') if rel_path.last == '.' + # RFC2396, Section 5.2, 6), d) + rel_path.push('') if rel_path.last == '.' || rel_path.last == '..' rel_path.delete('.') # RFC2396, Section 5.2, 6), e) |