FIX: when 'raw' started with non-image upload url it's not converted to short-url.
dd0f0494c6
This commit is contained in:
parent
dd0f0494c6
commit
dc6b13e4d2
|
@ -74,11 +74,13 @@ class InlineUploads
|
|||
markdown.scan(/(\n{2,}|\A)#{regexp}$/) do |match|
|
||||
if match[1].present?
|
||||
extension = match[1].split(".")[-1].downcase
|
||||
next if FileHelper.supported_images.exclude?(extension)
|
||||
|
||||
index = $~.offset(2)[0]
|
||||
indexes << index
|
||||
raw_matches << [match[1], match[1], +"![](#{PLACEHOLDER})", index]
|
||||
if FileHelper.supported_images.include?(extension)
|
||||
raw_matches << [match[1], match[1], +"![](#{PLACEHOLDER})", index]
|
||||
else
|
||||
raw_matches << [match[1], match[1], ++"#{Discourse.base_url}#{PATH_PLACEHOLDER}", index]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -231,13 +231,18 @@ RSpec.describe InlineUploads do
|
|||
it "should correct non image URLs to the short url" do
|
||||
SiteSetting.authorized_extensions = "mp4"
|
||||
upload = Fabricate(:video_upload)
|
||||
upload2 = Fabricate(:video_upload)
|
||||
|
||||
md = <<~MD
|
||||
#{GlobalSetting.cdn_url}#{upload.url}
|
||||
#{Discourse.base_url}#{upload.url}
|
||||
|
||||
#{Discourse.base_url}#{upload.url} #{Discourse.base_url}#{upload2.url}
|
||||
MD
|
||||
|
||||
expect(InlineUploads.process(md)).to eq(<<~MD)
|
||||
#{Discourse.base_url}#{upload.short_path}
|
||||
|
||||
#{Discourse.base_url}#{upload.short_path} #{Discourse.base_url}#{upload2.short_path}
|
||||
MD
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue