Commit 9fb1b0f4 by Brian John Committed by Jon Yurek

Honor the configured scheme for fog expiring URLs. In order to be

consistent with public URLs, this also changes the default behavior
for expiring URLs to use the https scheme rather than http.
parent 9292750d
......@@ -141,8 +141,9 @@ module Paperclip
def expiring_url(time = (Time.now + 3600), style_name = default_style)
time = convert_time(time)
if path(style_name) && directory.files.respond_to?(:get_http_url)
expiring_url = directory.files.get_http_url(path(style_name), time)
http_url_method = "get_#{scheme}_url"
if path(style_name) && directory.files.respond_to?(http_url_method)
expiring_url = directory.files.public_send(http_url_method, path(style_name), time)
if @options[:fog_host]
expiring_url.gsub!(/#{host_name_for_directory}/, dynamic_fog_host_for_style(style_name))
......
......@@ -320,6 +320,9 @@ describe Paperclip::Storage::Fog do
it "honors the scheme in public url" do
assert_match(/^http:\/\//, @dummy.avatar.url)
end
it "honors the scheme in expiring url" do
assert_match(/^http:\/\//, @dummy.avatar.expiring_url)
end
end
context "with scheme not set" do
......@@ -334,6 +337,9 @@ describe Paperclip::Storage::Fog do
it "provides HTTPS public url" do
assert_match(/^https:\/\//, @dummy.avatar.url)
end
it "provides HTTPS expiring url" do
assert_match(/^https:\/\//, @dummy.avatar.expiring_url)
end
end
context "with a valid bucket name for a subdomain" do
......@@ -344,7 +350,7 @@ describe Paperclip::Storage::Fog do
end
it "provides an url that expires in subdomain style" do
assert_match(/^http:\/\/papercliptests.s3.amazonaws.com\/avatars\/5k.png.+Expires=.+$/, @dummy.avatar.expiring_url)
assert_match(/^https:\/\/papercliptests.s3.amazonaws.com\/avatars\/5k.png.+Expires=.+$/, @dummy.avatar.expiring_url)
end
end
......@@ -392,7 +398,7 @@ describe Paperclip::Storage::Fog do
end
it "provides a url that expires in folder style" do
assert_match(/^http:\/\/s3.amazonaws.com\/this_is_invalid\/avatars\/5k.png.+Expires=.+$/, @dummy.avatar.expiring_url)
assert_match(/^https:\/\/s3.amazonaws.com\/this_is_invalid\/avatars\/5k.png.+Expires=.+$/, @dummy.avatar.expiring_url)
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment