DEV: improve subfolder inline logic

This follows up on #503a11cc88f with a spec
This commit is contained in:
Sam Saffron 2019-09-11 12:02:42 +10:00
parent 503a11cc88
commit 93b0ffc85c
2 changed files with 8 additions and 2 deletions

View File

@ -284,7 +284,10 @@ class InlineUploads
if cdn_url
regexps << /(#{cdn_url}\/uploads\/#{db}#{UPLOAD_REGEXP_PATTERN})/
regexps << /(#{cdn_url}#{GlobalSetting.relative_url_root}\/uploads\/#{db}#{UPLOAD_REGEXP_PATTERN})/ unless GlobalSetting.relative_url_root.nil?
if GlobalSetting.relative_url_root.present?
regexps << /(#{cdn_url}#{GlobalSetting.relative_url_root}\/uploads\/#{db}#{UPLOAD_REGEXP_PATTERN})/
end
end
if Discourse.store.external?

View File

@ -217,13 +217,16 @@ RSpec.describe InlineUploads do
end
it "should correct subfolder images" do
md = <<~MD
<img src="/community#{upload.url}">
#{Discourse.base_url}#{upload.url}
MD
expect(InlineUploads.process(md)).to eq(<<~MD)
![](#{upload.short_url})
![](#{upload.short_url})
MD
end
end