diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb index 2f6417f89..d5786c147 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 66a64a404..5da48e1e9 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 = "