FIX: `InlineUploads` matching on external bbcode img url.

FIX: InlineUploads matching on external bbcode img url.

diff --git a/app/services/inline_uploads.rb b/app/services/inline_uploads.rb
index c0a202e..60713c5 100644
--- a/app/services/inline_uploads.rb
+++ b/app/services/inline_uploads.rb
@@ -166,7 +166,9 @@ class InlineUploads
 
   def self.match_bbcode_img(markdown)
     markdown.scan(/(\[img\]\s?(.+)\s?\[\/img\])/) do |match|
-      yield(match[0], match[1], +"![](#{PLACEHOLDER})", $~.offset(0)[0]) if block_given?
+      if matched_uploads(match[1]).present? && block_given?
+        yield(match[0], match[1], +"![](#{PLACEHOLDER})", $~.offset(0)[0])
+      end
     end
   end
 
diff --git a/spec/services/inline_uploads_spec.rb b/spec/services/inline_uploads_spec.rb
index a1fdcc0..13e8c53 100644
--- a/spec/services/inline_uploads_spec.rb
+++ b/spec/services/inline_uploads_spec.rb
@@ -161,7 +161,9 @@ RSpec.describe InlineUploads do
 
       it "should correct bbcode img URLs to the short version" do
         md = <<~MD
+        [img]http://some.external.img[/img]
         [img]#{upload.url}[/img]
+        <img src="#{upload3.url}">
 
         [img]
         #{upload2.url}
@@ -169,7 +171,9 @@ RSpec.describe InlineUploads do
         MD
 
         expect(InlineUploads.process(md)).to eq(<<~MD)
+        [img]http://some.external.img[/img]
         ![](#{upload.short_url})
+        ![](#{upload3.short_url})
 
         ![](#{upload2.short_url})
         MD

GitHub sha: 7a0d031b

1 Like