A platform for community discussion. Free, open, simple.
FIX: when 'raw' started with non-image upload url it's not converted to short-url.
Vinoth Kannandc6b13e4d205
diff --git a/app/services/inline_uploads.rb b/app/services/inline_uploads.rbindex 6f1cedeb4a4..0473b1c81c1 100644--- a/app/services/inline_uploads.rb+++ b/app/services/inline_uploads.rb@@ -74,11 +74,13 @@ class InlineUploadsmarkdown.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], +"", index]+ if FileHelper.supported_images.include?(extension)+ raw_matches << [match[1], match[1], +"", index]+ else+ raw_matches << [match[1], match[1], ++"#{Discourse.base_url}#{PATH_PLACEHOLDER}", index]+ endendenddiff --git a/spec/services/inline_uploads_spec.rb b/spec/services/inline_uploads_spec.rbindex dd9c1090597..79f6e78d794 100644--- a/spec/services/inline_uploads_spec.rb+++ b/spec/services/inline_uploads_spec.rb@@ -231,13 +231,18 @@ RSpec.describe InlineUploads doit "should correct non image URLs to the short url" doSiteSetting.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}MDexpect(InlineUploads.process(md)).to eq(<<~MD)#{Discourse.base_url}#{upload.short_path}++ #{Discourse.base_url}#{upload.short_path} #{Discourse.base_url}#{upload2.short_path}MDend