mirror of
https://github.com/discourse/discourse.git
synced 2025-03-20 13:06:39 +08:00
FIX: Don't raise an error when the img attribute cannot be found
This commit is contained in:
parent
afe04b8bbb
commit
009e120e13
@ -158,6 +158,9 @@ class CookedPostProcessor
|
||||
|
||||
absolute_url = url
|
||||
absolute_url = Discourse.base_url_no_prefix + absolute_url if absolute_url =~ /^\/[^\/]/
|
||||
|
||||
return unless absolute_url
|
||||
|
||||
# FastImage fails when there's no scheme
|
||||
absolute_url = SiteSetting.scheme + ":" + absolute_url if absolute_url.start_with?("//")
|
||||
|
||||
|
@ -310,6 +310,12 @@ describe CookedPostProcessor do
|
||||
expect(cpp.get_size_from_attributes(img)).to eq([33, 100])
|
||||
end
|
||||
|
||||
it "doesn't raise an error with a weird url" do
|
||||
img = { 'src' => nil, 'height' => 100}
|
||||
SiteSetting.stubs(:crawl_images?).returns(true)
|
||||
expect(cpp.get_size_from_attributes(img)).to be_nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context ".get_size_from_image_sizes" do
|
||||
|
Loading…
x
Reference in New Issue
Block a user