FIX: 'local_cdn_url' method should work for local relative urls too.
This commit is contained in:
parent
99086edf85
commit
f92a6f7ac5
|
@ -71,7 +71,11 @@ class UrlHelper
|
||||||
|
|
||||||
def self.local_cdn_url(url)
|
def self.local_cdn_url(url)
|
||||||
return url if Discourse.asset_host.blank?
|
return url if Discourse.asset_host.blank?
|
||||||
url.sub(Discourse.base_url_no_prefix, Discourse.asset_host)
|
if url.start_with?("/#{Discourse.store.upload_path}/")
|
||||||
|
"#{Discourse.asset_host}#{url}"
|
||||||
|
else
|
||||||
|
url.sub(Discourse.base_url_no_prefix, Discourse.asset_host)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -119,4 +119,15 @@ describe UrlHelper do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#local_cdn_url" do
|
||||||
|
let(:url) { "/uploads/default/1X/575bcc2886bf7a39684b57ca90be85f7d399bbc7.png" }
|
||||||
|
let(:asset_host) { "//my.awesome.cdn" }
|
||||||
|
|
||||||
|
it "should return correct cdn url for local relative urls" do
|
||||||
|
Discourse.stubs(:asset_host).returns(asset_host)
|
||||||
|
cdn_url = UrlHelper.local_cdn_url(url)
|
||||||
|
expect(cdn_url).to eq("#{asset_host}#{url}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue