From 432f9b8d2fccfa17aef74b2793c56ab4bc7528c6 Mon Sep 17 00:00:00 2001 From: bootstraponline Date: Sat, 13 Oct 2012 12:57:58 -0600 Subject: [PATCH] Add test for #542 --- lib/gollum/markup.rb | 6 ++++++ test/test_markup.rb | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/gollum/markup.rb b/lib/gollum/markup.rb index 2f27d6fa..fcedd7f0 100644 --- a/lib/gollum/markup.rb +++ b/lib/gollum/markup.rb @@ -407,6 +407,12 @@ module Gollum presence = "present" end link = ::File.join(@wiki.base_path, page ? page.escaped_url_path : CGI.escape(link_name)) + + # //page is invalid + # strip all duplicate forward slashes using helpers.rb clean_url + # //page => /page + # link = one_leading_slash link + %{#{name}} end end diff --git a/test/test_markup.rb b/test/test_markup.rb index 285be397..bcb0c972 100644 --- a/test/test_markup.rb +++ b/test/test_markup.rb @@ -55,6 +55,22 @@ context "Markup" do # ######################################################################### + test "absolute link to non-existant page" do + @wiki.write_page("linktest", :markdown, "[[/page]]", commit_details) + + # "

a FooBar b

" + page = @wiki.page("linktest") + doc = Nokogiri::HTML page.formatted_data + paras = doc / :p + para = paras.first + anchors = para / :a + assert_equal 1, paras.size + assert_equal 1, anchors.size + assert_equal 'internal absent', anchors[0]['class'] + assert_equal '/Page', anchors[0]['href'] + assert_equal 'Page', anchors[0].text + end + test "double page links no space" do @wiki.write_page("Bilbo Baggins", :markdown, "a [[Foo]][[Bar]] b", commit_details)