Fix #542
This commit is contained in:
@@ -23,5 +23,12 @@ module Precious
|
||||
return url if url.nil?
|
||||
url.gsub('%2F','/').gsub(/^\/+/,'')
|
||||
end
|
||||
|
||||
def trim_leading_slash url
|
||||
return url if url.nil?
|
||||
url.gsub!('%2F','/')
|
||||
return '/' + url.gsub(/^\/+/,'') if url[0,1] == '/'
|
||||
url
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -411,7 +411,7 @@ module Gollum
|
||||
# //page is invalid
|
||||
# strip all duplicate forward slashes using helpers.rb clean_url
|
||||
# //page => /page
|
||||
# link = one_leading_slash link
|
||||
link = trim_leading_slash link
|
||||
|
||||
%{<a class="internal #{presence}" href="#{link}#{extra}">#{name}</a>}
|
||||
end
|
||||
|
||||
+2
-2
@@ -56,7 +56,7 @@ context "Markup" do
|
||||
#########################################################################
|
||||
|
||||
test "absolute link to non-existant page" do
|
||||
@wiki.write_page("linktest", :markdown, "[[/page]]", commit_details)
|
||||
@wiki.write_page("linktest", :markdown, "[[/Page]]", commit_details)
|
||||
|
||||
# "<p>a <a class=\"internal absent\" href=\"/Foo\">Foo</a><a class=\"internal absent\" href=\"/Bar\">Bar</a> b</p>"
|
||||
page = @wiki.page("linktest")
|
||||
@@ -68,7 +68,7 @@ context "Markup" do
|
||||
assert_equal 1, anchors.size
|
||||
assert_equal 'internal absent', anchors[0]['class']
|
||||
assert_equal '/Page', anchors[0]['href']
|
||||
assert_equal 'Page', anchors[0].text
|
||||
assert_equal '/Page', anchors[0].text
|
||||
end
|
||||
|
||||
test "double page links no space" do
|
||||
|
||||
Reference in New Issue
Block a user