@@ -376,21 +376,15 @@ def public_url
376
376
when 'AWS'
377
377
# check if some endpoint is set in fog_credentials
378
378
if @uploader . fog_credentials . has_key? ( :endpoint )
379
- if !@uploader . fog_aws_fips
380
- "#{ @uploader . fog_credentials [ :endpoint ] } /#{ @uploader . fog_directory } /#{ encoded_path } "
381
- else
382
- warn 'Use of options :endpoint and :fog_aws_fips=true together will fail, as FIPS endpoints do not support path-style URLs.'
383
- nil
384
- end
379
+ raise 'fog_aws_fips = true is incompatible with :endpoint, as FIPS endpoints do not support path-style URLs.' if @uploader . fog_aws_fips
380
+ "#{ @uploader . fog_credentials [ :endpoint ] } /#{ @uploader . fog_directory } /#{ encoded_path } "
385
381
else
386
382
protocol = @uploader . fog_use_ssl_for_aws ? "https" : "http"
387
383
388
384
subdomain_regex = /^(?:[a-z]|\d (?!\d {0,2}(?:\d {1,3}){3}$))(?:[a-z0-9\. ]|(?![\- ])|\- (?![\. ])){1,61}[a-z0-9]$/
389
385
# To use the virtual-hosted style, the bucket name needs to be representable as a subdomain
390
386
use_virtual_hosted_style = @uploader . fog_directory . to_s =~ subdomain_regex && !( protocol == 'https' && @uploader . fog_directory =~ /\. / )
391
387
392
- return nil if !use_virtual_hosted_style && @uploader . fog_aws_fips # FIPS Endpoints can only be used with Virtual Hosted-Style addressing.
393
-
394
388
region = @uploader . fog_credentials [ :region ] . to_s
395
389
regional_host = 's3.amazonaws.com' # used for DEFAULT_S3_REGION or no region set
396
390
if @uploader . fog_aws_fips
@@ -403,6 +397,7 @@ def public_url
403
397
regional_host = 's3-accelerate.amazonaws.com' if @uploader . fog_aws_accelerate
404
398
"#{ protocol } ://#{ @uploader . fog_directory } .#{ regional_host } /#{ encoded_path } "
405
399
else # directory is not a valid subdomain, so use path style for access
400
+ raise 'FIPS Endpoints can only be used with Virtual Hosted-Style addressing.' if @uploader . fog_aws_fips
406
401
"#{ protocol } ://#{ regional_host } /#{ @uploader . fog_directory } /#{ encoded_path } "
407
402
end
408
403
end
0 commit comments