public
Fork of technoweenie/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/b3b0p/mephisto.git
add first specs

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@3051 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Fri Nov 23 18:06:05 -0800 2007
commit  fa95f30d1e74cc5af558fe9767e6fe133730e343
tree    9dc8e414698939a96529390e68697ee5f72670c5
parent  989dbfc3b82caa64f0d92ce39707a0a646e689d6
...
12
13
14
 
15
16
 
 
17
18
19
...
12
13
14
15
16
 
17
18
19
20
21
0
@@ -12,8 +12,10 @@ module Mephisto
0
 
0
       def absolute_url(*path)
0
         return "#{relative_url_root}/" if path.empty?
0
+ is_absolute = path.first.to_s[/(^\/)/]
0
         path.collect! { |p| p.to_s.gsub /(^\/)|(\/$)/, '' }
0
- path.empty? ? "#{relative_url_root}/" : path.unshift(relative_url_root).join('/')
0
+ path.unshift(is_absolute ? '' : relative_url_root)
0
+ path * '/'
0
       end
0
     end
0
   end
...
22
23
24
25
 
26
27
28
...
49
50
51
52
 
53
54
55
56
 
57
58
59
...
22
23
24
 
25
26
27
28
...
49
50
51
 
52
53
54
55
 
56
57
58
59
0
@@ -22,7 +22,7 @@ context "Default Url" do
0
   end
0
   
0
   specify "should join path ending with a slash" do
0
- assert_equal '/foo/bar/baz', absolute_url('/foo/bar/baz/')
0
+ assert_equal '/foo/bar/baz', absolute_url('foo/bar/baz/')
0
   end
0
 end
0
 
0
@@ -49,10 +49,10 @@ context "Custom Relative Url" do
0
   end
0
   
0
   specify "should join absolute path" do
0
- assert_equal '/blog/foo/bar/baz.html', absolute_url('/foo/bar/baz.html')
0
+ assert_equal '/foo/bar/baz.html', absolute_url('/foo/bar/baz.html')
0
   end
0
   
0
   specify "should join path ending with a slash" do
0
- assert_equal '/blog/foo/bar/baz', absolute_url('/foo/bar/baz/')
0
+ assert_equal '/blog/foo/bar/baz', absolute_url('foo/bar/baz/')
0
   end
0
 end
0
\ No newline at end of file

Comments

    No one has commented yet.