FIX: inline_uploads not working on subfolder setups
This commit is contained in:
parent
6b6b0f09c4
commit
cd894b7d17
|
@ -278,7 +278,7 @@ class InlineUploads
|
||||||
/(upload:\/\/([a-zA-Z0-9]+)[a-zA-Z0-9\.]*)/,
|
/(upload:\/\/([a-zA-Z0-9]+)[a-zA-Z0-9\.]*)/,
|
||||||
/(\/uploads\/short-url\/([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\.]*)/,
|
/(#{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})/,
|
/(#{base_url}\/uploads\/#{db}#{UPLOAD_REGEXP_PATTERN})/,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -206,6 +206,28 @@ RSpec.describe InlineUploads do
|
||||||
MD
|
MD
|
||||||
end
|
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
|
it "should correct raw image URLs to the short url and paths" do
|
||||||
md = <<~MD
|
md = <<~MD
|
||||||
#{Discourse.base_url}#{upload.url}
|
#{Discourse.base_url}#{upload.url}
|
||||||
|
|
Loading…
Reference in New Issue