From b7a0a295c086156eb22cfa994201b2d9036ff43c Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Wed, 10 Jun 2015 18:56:44 +1000 Subject: [PATCH] FIX: s3 cdn would break cooking if tag had no src --- lib/pretty_text.rb | 1 + spec/components/pretty_text_spec.rb | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb index 2f6417f8949..d5786c147f7 100644 --- a/lib/pretty_text.rb +++ b/lib/pretty_text.rb @@ -224,6 +224,7 @@ module PrettyText def self.add_s3_cdn(doc) doc.css("img").each do |img| + next unless img["src"] img["src"] = img["src"].sub(Discourse.store.absolute_base_url, SiteSetting.s3_cdn_url) end end diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb index 66a64a404b3..5da48e1e932 100644 --- a/spec/components/pretty_text_spec.rb +++ b/spec/components/pretty_text_spec.rb @@ -323,8 +323,9 @@ describe PrettyText do SiteSetting.s3_upload_bucket = "test" SiteSetting.s3_cdn_url = "https://awesome.cdn" - raw = "