mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
FIX: Uploads not being linked correctly to posts.
Regression due to 1f636c445b
.
This commit is contained in:
@ -177,7 +177,7 @@ class Upload < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
return if uri&.path.blank?
|
return if uri&.path.blank?
|
||||||
data = uri.path.match(/(\/original\/\dX\/[\/\.\w]+\/([a-zA-Z0-9]+)[\.\w]+)/)
|
data = uri.path.match(/(\/original\/\dX[\/\.\w]*\/([a-zA-Z0-9]+)[\.\w]+)/)
|
||||||
return if data.blank?
|
return if data.blank?
|
||||||
sha1 = data[2]
|
sha1 = data[2]
|
||||||
upload = nil
|
upload = nil
|
||||||
|
@ -82,6 +82,15 @@ describe Upload do
|
|||||||
expect(Upload.get_from_url(upload.url)).to eq(upload)
|
expect(Upload.get_from_url(upload.url)).to eq(upload)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'for a url without a tree' do
|
||||||
|
let(:url) { "/uploads/default/original/1X/#{sha1}.png" }
|
||||||
|
let(:upload) { Fabricate(:upload, url: url, sha1: sha1) }
|
||||||
|
|
||||||
|
it 'should return the right upload' do
|
||||||
|
expect(Upload.get_from_url(upload.url)).to eq(upload)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "works when using a cdn" do
|
it "works when using a cdn" do
|
||||||
begin
|
begin
|
||||||
original_asset_host = Rails.configuration.action_controller.asset_host
|
original_asset_host = Rails.configuration.action_controller.asset_host
|
||||||
|
Reference in New Issue
Block a user