Do not rewrite relative links for system notes

This commit is contained in:
Mario de la Ossa 2019-06-18 19:28:18 -06:00
parent ba952d53c5
commit 35a39c1d34
No known key found for this signature in database
GPG key ID: 20CA8F4C6A20761B
4 changed files with 15 additions and 1 deletions

View file

@ -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)

View file

@ -0,0 +1,5 @@
---
title: Fixed 'diff version changes' link not working
merge_request: 29825
author:
type: fixed

View file

@ -17,6 +17,8 @@ module Banzai
include Gitlab::Utils::StrongMemoize
def call
return doc if context[:system_note]
@uri_types = {}
clear_memoization(:linkable_files)

View file

@ -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'