summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMario de la Ossa <mariodelaossa@gmail.com>2019-06-18 19:28:18 -0600
committerMario de la Ossa <mariodelaossa@gmail.com>2019-06-20 10:15:59 -0600
commit35a39c1d3476f0398a2846772e075b9a003bd623 (patch)
treed05c573104c889b138cfd3a22271bcce154c1abe
parentba952d53c5782e49b59ba3e5dd89c2c1eca02c80 (diff)
downloadgitlab-ce-bug/63162-duplicate_path_in_links.tar.gz
Do not rewrite relative links for system notesbug/63162-duplicate_path_in_links
-rw-r--r--app/models/note.rb2
-rw-r--r--changelogs/unreleased/bug-63162-duplicate_path_in_links.yml5
-rw-r--r--lib/banzai/filter/relative_link_filter.rb2
-rw-r--r--spec/lib/banzai/filter/relative_link_filter_spec.rb7
4 files changed, 15 insertions, 1 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index 15271c68a9e..b55af7d9b5e 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -457,7 +457,7 @@ class Note < ApplicationRecord
end
def banzai_render_context(field)
- super.merge(noteable: noteable)
+ super.merge(noteable: noteable, system_note: system?)
end
def retrieve_upload(_identifier, paths)
diff --git a/changelogs/unreleased/bug-63162-duplicate_path_in_links.yml b/changelogs/unreleased/bug-63162-duplicate_path_in_links.yml
new file mode 100644
index 00000000000..d3f246492fb
--- /dev/null
+++ b/changelogs/unreleased/bug-63162-duplicate_path_in_links.yml
@@ -0,0 +1,5 @@
+---
+title: Fixed 'diff version changes' link not working
+merge_request: 29825
+author:
+type: fixed
diff --git a/lib/banzai/filter/relative_link_filter.rb b/lib/banzai/filter/relative_link_filter.rb
index 199b3533cf4..80c84c0f622 100644
--- a/lib/banzai/filter/relative_link_filter.rb
+++ b/lib/banzai/filter/relative_link_filter.rb
@@ -17,6 +17,8 @@ module Banzai
include Gitlab::Utils::StrongMemoize
def call
+ return doc if context[:system_note]
+
@uri_types = {}
clear_memoization(:linkable_files)
diff --git a/spec/lib/banzai/filter/relative_link_filter_spec.rb b/spec/lib/banzai/filter/relative_link_filter_spec.rb
index dad0a5535c0..8ff971114d6 100644
--- a/spec/lib/banzai/filter/relative_link_filter_spec.rb
+++ b/spec/lib/banzai/filter/relative_link_filter_spec.rb
@@ -101,6 +101,13 @@ describe Banzai::Filter::RelativeLinkFilter do
.to eq "/#{project_path}/blob/#{ref}/doc/api/README.md"
end
+ it 'does not modify relative URLs in system notes' do
+ path = "#{project_path}/merge_requests/1/diffs"
+ doc = filter(link(path), system_note: true)
+
+ expect(doc.at_css('a')['href']).to eq path
+ end
+
it 'ignores absolute URLs with two leading slashes' do
doc = filter(link('//doc/api/README.md'))
expect(doc.at_css('a')['href']).to eq '//doc/api/README.md'