Skip to content
Permalink
Browse files

FIX: inline_uploads not working on subfolder setups

  • Loading branch information
SamSaffron committed Sep 5, 2019
1 parent 6b6b0f0 commit cd894b7d17a5d0712facb943229cdb2504818a7f
Showing with 23 additions and 1 deletion.
  1. +1 −1 app/services/inline_uploads.rb
  2. +22 −0 spec/services/inline_uploads_spec.rb
@@ -278,7 +278,7 @@ def self.matched_uploads(node)
/(upload:\/\/([a-zA-Z0-9]+)[a-zA-Z0-9\.]*)/,
/(\/uploads\/short-url\/([a-zA-Z0-9]+)[a-zA-Z0-9\.]*)/,
/(#{base_url}\/uploads\/short-url\/([a-zA-Z0-9]+)[a-zA-Z0-9\.]*)/,
/(\/uploads\/#{db}#{UPLOAD_REGEXP_PATTERN})/,
/(#{GlobalSetting.relative_url_root}\/uploads\/#{db}#{UPLOAD_REGEXP_PATTERN})/,
/(#{base_url}\/uploads\/#{db}#{UPLOAD_REGEXP_PATTERN})/,
]

@@ -206,6 +206,28 @@
MD
end

context "subfolder" do
before do
global_setting :relative_url_root, "/community"
ActionController::Base.config.relative_url_root = "/community"
end

after do
ActionController::Base.config.relative_url_root = nil
end

it "should correct subfolder images" do

md = <<~MD
<img src="/community#{upload.url}">
MD

expect(InlineUploads.process(md)).to eq(<<~MD)
![](#{upload.short_url})
MD
end
end

it "should correct raw image URLs to the short url and paths" do
md = <<~MD
#{Discourse.base_url}#{upload.url}

1 comment on commit cd894b7

@discoursebot

This comment has been minimized.

Copy link

discoursebot commented on cd894b7 Sep 5, 2019

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/just-updated-discourse-but-dashboard-says-it-was-6-hours-ago/123479/6

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