FIX: when 'raw' started with non-image upload url it's not converted to short-url.

FIX: when ‘raw’ started with non-image upload url it’s not converted to short-url.

dd0f0494c64e75046a4f26e3e46c132edb750cb0

diff --git a/app/services/inline_uploads.rb b/app/services/inline_uploads.rb
index 6f1cede..0473b1c 100644
--- a/app/services/inline_uploads.rb
+++ b/app/services/inline_uploads.rb
@@ -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
 
diff --git a/spec/services/inline_uploads_spec.rb b/spec/services/inline_uploads_spec.rb
index dd9c109..79f6e78 100644
--- a/spec/services/inline_uploads_spec.rb
+++ b/spec/services/inline_uploads_spec.rb
@@ -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

GitHub sha: dc6b13e4

SPEC: add additional test with 'cdn_url'.

What is the ++ for?

1 Like

Fix typo in dc6b13e4d205fd148d10d56d1f38f0b12d55825d.