Fixed Gollum pages link url expansion to render correctly in preview
This commit is contained in:
parent
b69f8a62b2
commit
7d56d592cd
|
@ -144,12 +144,18 @@ module Banzai
|
|||
# if it is not.
|
||||
def process_page_link_tag(parts)
|
||||
if parts.size == 1
|
||||
url = parts[0].strip
|
||||
reference = parts[0].strip
|
||||
else
|
||||
name, url = *parts.compact.map(&:strip)
|
||||
name, reference = *parts.compact.map(&:strip)
|
||||
end
|
||||
|
||||
content_tag(:a, name || url, href: url)
|
||||
if url?(reference)
|
||||
href = reference
|
||||
else
|
||||
href = ::File.join(project_wiki_base_path, reference)
|
||||
end
|
||||
|
||||
content_tag(:a, name || reference, href: href)
|
||||
end
|
||||
|
||||
def project_wiki
|
||||
|
|
|
@ -70,20 +70,22 @@ describe Banzai::Filter::GollumTagsFilter, lib: true do
|
|||
end
|
||||
|
||||
context 'linking internal resources' do
|
||||
it "the created link's text will be equal to the resource's text" do
|
||||
it "the created link's text will include the resource's text and project_wiki_base_path" do
|
||||
tag = '[[wiki-slug]]'
|
||||
doc = filter("See #{tag}", project_wiki: project_wiki)
|
||||
expected_path = ::File.join(project_wiki.wiki_base_path, 'wiki-slug')
|
||||
|
||||
expect(doc.at_css('a').text).to eq 'wiki-slug'
|
||||
expect(doc.at_css('a')['href']).to eq 'wiki-slug'
|
||||
expect(doc.at_css('a')['href']).to eq expected_path
|
||||
end
|
||||
|
||||
it "the created link's text will be link-text" do
|
||||
tag = '[[link-text|wiki-slug]]'
|
||||
doc = filter("See #{tag}", project_wiki: project_wiki)
|
||||
expected_path = ::File.join(project_wiki.wiki_base_path, 'wiki-slug')
|
||||
|
||||
expect(doc.at_css('a').text).to eq 'link-text'
|
||||
expect(doc.at_css('a')['href']).to eq 'wiki-slug'
|
||||
expect(doc.at_css('a')['href']).to eq expected_path
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue