Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactor previous: move complexity into s3_permissions method

  • Loading branch information...
commit 45e4b075419b3ce2f10f1c53cc2bc6936f3e4c55 1 parent 5ce04ed
@jyurek jyurek authored
Showing with 8 additions and 8 deletions.
  1. +8 −8 lib/paperclip/storage/s3.rb
View
16 lib/paperclip/storage/s3.rb
@@ -150,16 +150,13 @@ def sanitize_hash(hash)
end
Paperclip.interpolates(:s3_alias_url) do |attachment, style|
- url_prefix = (s3_protocol = attachment.s3_protocol(style)).present? ? "#{s3_protocol}:" : ""
- "#{url_prefix}//#{attachment.s3_host_alias}/#{attachment.path(style).gsub(%r{^/}, "")}"
+ "#{attachment.s3_protocol(style)}//#{attachment.s3_host_alias}/#{attachment.path(style).gsub(%r{^/}, "")}"
end unless Paperclip::Interpolations.respond_to? :s3_alias_url
Paperclip.interpolates(:s3_path_url) do |attachment, style|
- url_prefix = (s3_protocol = attachment.s3_protocol(style)).present? ? "#{s3_protocol}:" : ""
- "#{url_prefix}//#{attachment.s3_host_name}/#{attachment.bucket_name}/#{attachment.path(style).gsub(%r{^/}, "")}"
+ "#{attachment.s3_protocol(style)}//#{attachment.s3_host_name}/#{attachment.bucket_name}/#{attachment.path(style).gsub(%r{^/}, "")}"
end unless Paperclip::Interpolations.respond_to? :s3_path_url
Paperclip.interpolates(:s3_domain_url) do |attachment, style|
- url_prefix = (s3_protocol = attachment.s3_protocol(style)).present? ? "#{s3_protocol}:" : ""
- "#{url_prefix}//#{attachment.bucket_name}.#{attachment.s3_host_name}/#{attachment.path(style).gsub(%r{^/}, "")}"
+ "#{attachment.s3_protocol(style)}//#{attachment.bucket_name}.#{attachment.s3_host_name}/#{attachment.path(style).gsub(%r{^/}, "")}"
end unless Paperclip::Interpolations.respond_to? :s3_domain_url
Paperclip.interpolates(:asset_host) do |attachment, style|
"#{attachment.path(style).gsub(%r{^/}, "")}"
@@ -284,11 +281,14 @@ def s3_permissions(style = default_style)
end
def s3_protocol(style = default_style)
- if @s3_protocol.is_a?(Proc)
+ protocol = if @s3_protocol.is_a?(Proc)
@s3_protocol.call(style, self)
else
@s3_protocol
end
+
+ protocol = protocol.split(":").first + ":" unless protocol.empty?
+ protocol
end
def create_bucket
@@ -360,7 +360,7 @@ def find_credentials creds
private :find_credentials
def use_secure_protocol?(style_name)
- s3_protocol(style_name) == "https"
+ s3_protocol(style_name) == "https:"
end
private :use_secure_protocol?
end
Please sign in to comment.
Something went wrong with that request. Please try again.