Commit 4e659486 authored by Stan Hu's avatar Stan Hu

Merge branch 'issue_205151' into 'master'

205151-match trailing slash in GitLab-Flavored Markdown References

See merge request gitlab-org/gitlab!42484
parents b531e530 84b2576d
......@@ -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
......@@ -174,7 +174,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