diff --git a/lib/url_helper.rb b/lib/url_helper.rb index 7db387f1d..24f6192ac 100644 --- a/lib/url_helper.rb +++ b/lib/url_helper.rb @@ -18,7 +18,7 @@ class UrlHelper end def self.schemaless(url) - url.sub(/^https?:/, "") + url.sub(/^http:/, "") end end diff --git a/spec/components/cooked_post_processor_spec.rb b/spec/components/cooked_post_processor_spec.rb index b14823ead..130686304 100644 --- a/spec/components/cooked_post_processor_spec.rb +++ b/spec/components/cooked_post_processor_spec.rb @@ -317,7 +317,7 @@ describe CookedPostProcessor do context "when CDN is enabled" do - it "uses schemaless CDN url for uploads" 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 @@ -325,6 +325,14 @@ describe CookedPostProcessor do ' 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 + ' + end + end end diff --git a/spec/components/url_helper_spec.rb b/spec/components/url_helper_spec.rb index f0e98b708..ae2c37d1e 100644 --- a/spec/components/url_helper_spec.rb +++ b/spec/components/url_helper_spec.rb @@ -56,9 +56,9 @@ describe UrlHelper do describe "#schemaless" do - it "removes http or https schemas only" do + it "removes http schemas only" do expect(UrlHelper.schemaless("http://www.discourse.org")).to eq("//www.discourse.org") - expect(UrlHelper.schemaless("https://secure.discourse.org")).to eq("//secure.discourse.org") + expect(UrlHelper.schemaless("https://secure.discourse.org")).to eq("https://secure.discourse.org") expect(UrlHelper.schemaless("ftp://ftp.discourse.org")).to eq("ftp://ftp.discourse.org") end