mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: properly support HTTPS CDN on HTTP site
Previously we changed all CDN links to schemaless. This is desirable for non HTTPS sites, to ease migration to HTTPS. It is not desirable for secure sites. Once site is secure or CDN is secure a rebake should be required to move it back to non-secure.
This commit is contained in:
parent
b22c890e4b
commit
7a5a195dc0
3 changed files with 12 additions and 4 deletions
|
@ -18,7 +18,7 @@ class UrlHelper
|
|||
end
|
||||
|
||||
def self.schemaless(url)
|
||||
url.sub(/^https?:/, "")
|
||||
url.sub(/^http:/, "")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -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 '<a href="//my.cdn.com/uploads/default/2/2345678901234567.jpg">Link</a>
|
||||
|
@ -325,6 +325,14 @@ describe CookedPostProcessor do
|
|||
<img src="http://foo.bar/image.png">'
|
||||
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 '<a href="https://my.cdn.com/uploads/default/2/2345678901234567.jpg">Link</a>
|
||||
<img src="https://my.cdn.com/uploads/default/1/1234567890123456.jpg"><a href="http://www.google.com">Google</a>
|
||||
<img src="http://foo.bar/image.png">'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue