Commit a85fe355 authored by Stan Hu's avatar Stan Hu

Merge branch 'jc-fix-relative-link-filter' into 'master'

Do not load uri types if there are no linkable attributes

Closes #33407

See merge request gitlab-org/gitlab!18241
parents 6d8d03b3 f27415d7
...@@ -21,6 +21,7 @@ module Banzai ...@@ -21,6 +21,7 @@ module Banzai
return doc if context[:system_note] return doc if context[:system_note]
clear_memoization(:linkable_files) clear_memoization(:linkable_files)
clear_memoization(:linkable_attributes)
load_uri_types load_uri_types
...@@ -35,10 +36,9 @@ module Banzai ...@@ -35,10 +36,9 @@ module Banzai
def load_uri_types def load_uri_types
return unless linkable_files? return unless linkable_files?
return unless linkable_attributes.present?
return {} unless repository return {} unless repository
clear_memoization(:linkable_attributes)
@uri_types = request_path.present? ? get_uri_types([request_path]) : {} @uri_types = request_path.present? ? get_uri_types([request_path]) : {}
paths = linkable_attributes.flat_map do |attr| paths = linkable_attributes.flat_map do |attr|
......
...@@ -228,6 +228,12 @@ describe Banzai::Filter::RelativeLinkFilter do ...@@ -228,6 +228,12 @@ describe Banzai::Filter::RelativeLinkFilter do
expect(doc.at_css('a')['href']).to eq 'http://example.com' expect(doc.at_css('a')['href']).to eq 'http://example.com'
end end
it 'does not call gitaly' do
filter(link('http://example.com'))
expect(described_class).not_to receive(:get_blob_types)
end
it 'supports Unicode filenames' do it 'supports Unicode filenames' do
path = 'files/images/한글.png' path = 'files/images/한글.png'
escaped = Addressable::URI.escape(path) escaped = Addressable::URI.escape(path)
......
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