diff --git a/lib/url_helper.rb b/lib/url_helper.rb index 1a8382ecda5..fe9e62d2863 100644 --- a/lib/url_helper.rb +++ b/lib/url_helper.rb @@ -3,8 +3,7 @@ class UrlHelper def self.is_local(url) url.present? && ( Discourse.store.has_been_uploaded?(url) || - !!(url =~ /^\/assets\//) || - !!(url =~ /^\/plugins\//) || + !!(url =~ /^\/(assets|plugins|images)\//) || url.start_with?(Discourse.asset_host || Discourse.base_url_no_prefix) ) end diff --git a/spec/components/cooked_post_processor_spec.rb b/spec/components/cooked_post_processor_spec.rb index b177886674c..49f1b992ce5 100644 --- a/spec/components/cooked_post_processor_spec.rb +++ b/spec/components/cooked_post_processor_spec.rb @@ -384,7 +384,7 @@ describe CookedPostProcessor do it "uses schemaless url for uploads" do cpp.optimize_urls - expect(cpp.html).to match_html '

Link

Google

text.txt (20 Bytes)

' + expect(cpp.html).to match_html '

Link

Google

text.txt (20 Bytes)
:smile:

' end context "when CDN is enabled" do @@ -392,20 +392,20 @@ describe CookedPostProcessor do it "does use schemaless CDN url for http uploads" do Rails.configuration.action_controller.stubs(:asset_host).returns("http://my.cdn.com") cpp.optimize_urls - expect(cpp.html).to match_html '

Link

Google

text.txt (20 Bytes)

' + expect(cpp.html).to match_html '

Link

Google

text.txt (20 Bytes)
:smile:

' end it "does not use schemaless CDN url for https uploads" do Rails.configuration.action_controller.stubs(:asset_host).returns("https://my.cdn.com") cpp.optimize_urls - expect(cpp.html).to match_html '

Link

Google

text.txt (20 Bytes)

' + expect(cpp.html).to match_html '

Link

Google

text.txt (20 Bytes)
:smile:

' end it "does not use CDN when login is required" do SiteSetting.login_required = true Rails.configuration.action_controller.stubs(:asset_host).returns("http://my.cdn.com") cpp.optimize_urls - expect(cpp.html).to match_html '

Link

Google

text.txt (20 Bytes)

' + expect(cpp.html).to match_html '

Link

Google

text.txt (20 Bytes)
:smile:

' end end diff --git a/spec/fabricators/post_fabricator.rb b/spec/fabricators/post_fabricator.rb index 6b3ff433968..520271a6cfd 100644 --- a/spec/fabricators/post_fabricator.rb +++ b/spec/fabricators/post_fabricator.rb @@ -101,6 +101,7 @@ Fabricator(:post_with_uploads_and_links, from: :post) do Google text.txt (20 Bytes) +:smile: ' end