Compare commits

...

2 Commits

Author SHA1 Message Date
dongzhimin-xz
9ff93cf7f9
Merge 5c41bb0747 into 624c024766 2025-09-03 10:07:13 +00:00
dongzhimin
5c41bb0747 fixed issue would cause bucket name and endpoint leaking 2025-08-24 20:10:51 +08:00

View File

@ -23,7 +23,8 @@ module RoutingHelper
def expiring_asset_url(attachment, expires_in) def expiring_asset_url(attachment, expires_in)
case Paperclip::Attachment.default_options[:storage] case Paperclip::Attachment.default_options[:storage]
when :s3, :azure when :s3, :azure
attachment.expiring_url(expires_in.to_i) url = attachment.expiring_url(expires_in.to_i)
ENV.key?('S3_ALIAS_HOST') ? url.sub("#{ENV.fetch('S3_ENDPOINT')}/#{ENV.fetch('S3_BUCKET')}", "https://#{ENV.fetch('S3_ALIAS_HOST')}") : url
when :fog when :fog
if Paperclip::Attachment.default_options.dig(:fog_credentials, :openstack_temp_url_key).present? if Paperclip::Attachment.default_options.dig(:fog_credentials, :openstack_temp_url_key).present?
attachment.expiring_url(expires_in.from_now) attachment.expiring_url(expires_in.from_now)