when linking images, assume '.' is the root path

This commit is contained in:
rick
2010-07-14 13:42:21 -07:00
parent ecbb902e62
commit 5135de1c3f
2 changed files with 13 additions and 1 deletions
+1 -1
View File
@@ -214,7 +214,7 @@ module Gollum
if name =~ /^\//
@wiki.file(name[1..-1], @version)
else
path = ::File.join(@dir, name)
path = @dir == '.' ? name : ::File.join(@dir, name)
@wiki.file(path, @version)
end
end
+12
View File
@@ -71,6 +71,18 @@ context "Markup" do
assert_equal %{<p>a <img src="/wiki/alpha.jpg" /> <a href="/wiki/alpha.jpg">a</a> b</p>}, output
end
test "image with relative path on root" do
@wiki = Gollum::Wiki.new(@path, :base_path => '/wiki')
index = @wiki.repo.index
index.add("alpha.jpg", "hi")
index.add("Bilbo-Baggins.md", "a [[alpha.jpg]] [[a | alpha.jpg]] b")
index.commit("Add alpha.jpg")
page = @wiki.page("Bilbo Baggins")
output = Gollum::Markup.new(page).render
assert_equal %{<p>a <img src="/wiki/alpha.jpg" /> <a href="/wiki/alpha.jpg">a</a> b</p>}, output
end
test "image with relative path" do
@wiki = Gollum::Wiki.new(@path, :base_path => '/wiki')
index = @wiki.repo.index