Commit 84b2576d authored by Jean Dupuis's avatar Jean Dupuis Committed by Stan Hu

205151-match trailing slash in GitLab-Flavored Markdown References

parent b4991678
......@@ -85,7 +85,7 @@ module Referable
\/#{route.is_a?(Regexp) ? route : Regexp.escape(route)}
\/#{pattern}
(?<path>
(\/[a-z0-9_=-]+)*
(\/[a-z0-9_=-]+)*\/*
)?
(?<query>
\?[a-z0-9_=-]+
......
title: 'Rendering trailing slash in reference links (issue 205151)'
merge_request: 42484
author:
type: fixed
......@@ -170,7 +170,7 @@ module EE
\/-\/epics
\/(?<epic>\d+)
(?<path>
(\/[a-z0-9_=-]+)*
(\/[a-z0-9_=-]+)*\/*
)?
(?<query>
\?[a-z0-9_=-]+
......
......@@ -189,6 +189,7 @@ RSpec.describe Banzai::Filter::EpicReferenceFilter do
context 'url reference' do
let(:link) { urls.group_epic_url(epic.group, epic) }
let(:text) { "Check #{link}" }
let(:project) { create(:project) }
before do
epic.update_attribute(:group_id, another_group.id)
......@@ -205,6 +206,12 @@ RSpec.describe Banzai::Filter::EpicReferenceFilter do
it 'includes default classes' do
expect(doc(text).css('a').first.attr('class')).to eq('gfm gfm-epic has-tooltip')
end
it 'matches link reference with trailing slash' do
doc2 = reference_filter("Fixed (#{link}/.)")
expect(doc2).to match(%r{\(#{Regexp.escape(epic.to_reference(group))}\.\)})
end
end
context 'full cross-refererence in a link href' do
......
......@@ -296,6 +296,12 @@ RSpec.describe Banzai::Filter::IssueReferenceFilter do
.to eq reference
end
it 'link with trailing slash' do
doc = reference_filter("Fixed (#{issue_url + "/"}.)")
expect(doc.to_html).to match(%r{\(<a.+>#{Regexp.escape(issue.to_reference(project))}</a>\.\)})
end
it 'links with adjacent text' do
doc = reference_filter("Fixed (#{reference}.)")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment