DEV: improve subfolder inline logic

DEV: improve subfolder inline logic

This follows up on #503a11cc88f with a spec

diff --git a/app/services/inline_uploads.rb b/app/services/inline_uploads.rb
index 7ffa429..d8ddc4e 100644
--- a/app/services/inline_uploads.rb
+++ b/app/services/inline_uploads.rb
@@ -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?
diff --git a/spec/services/inline_uploads_spec.rb b/spec/services/inline_uploads_spec.rb
index 41646c3..b42f7c7 100644
--- a/spec/services/inline_uploads_spec.rb
+++ b/spec/services/inline_uploads_spec.rb
@@ -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

GitHub sha: 93b0ffc8

2 Likes