Skip to content
Permalink
Browse files

DEV: improve subfolder inline logic

This follows up on #503a11cc88f with a spec
  • Loading branch information...
SamSaffron committed Sep 11, 2019
1 parent 503a11c commit 93b0ffc85c951a16165b677e738c92df5af6693d
Showing with 8 additions and 2 deletions.
  1. +4 −1 app/services/inline_uploads.rb
  2. +4 −1 spec/services/inline_uploads_spec.rb
@@ -284,7 +284,10 @@ def self.matched_uploads(node)

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?
@@ -217,13 +217,16 @@
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

0 comments on commit 93b0ffc

Please sign in to comment.
You can’t perform that action at this time.