diff --git a/lib/gollum/markup.rb b/lib/gollum/markup.rb index c2b2b3c0..f97d973d 100644 --- a/lib/gollum/markup.rb +++ b/lib/gollum/markup.rb @@ -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 diff --git a/test/test_markup.rb b/test/test_markup.rb index a02c4f5b..d14a4ef5 100644 --- a/test/test_markup.rb +++ b/test/test_markup.rb @@ -71,6 +71,18 @@ context "Markup" do assert_equal %{

a a b

}, 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 %{

a a b

}, output + end + test "image with relative path" do @wiki = Gollum::Wiki.new(@path, :base_path => '/wiki') index = @wiki.repo.index