Merge commit '1fc165de02d79294c8a218f5fa82bcd477484ca1' into glitch-soc/merge-upstream

Conflicts:
- `.env.production.sample`:
  Upstream added a block of three environment variables, while glitch-soc
  has a different version of the file overall.
  Added upstream's changes.
- `app/helpers/application_helper.rb`:
  Upstream added a helper, while glitch-soc had extra helpers.
  Added upstream's helper.
This commit is contained in:
Claire
2024-10-19 19:13:32 +02:00
283 changed files with 2777 additions and 1360 deletions

View File

@@ -40,7 +40,7 @@ class ContentSecurityPolicy
end
def cdn_host_value
s3_alias_host || s3_cloudfront_host || azure_alias_host || s3_hostname_host
s3_alias_host || s3_cloudfront_host || azure_alias_host || s3_hostname_host || swift_object_url
end
def paperclip_root_url
@@ -76,6 +76,14 @@ class ContentSecurityPolicy
host_to_url ENV.fetch('S3_HOSTNAME', nil)
end
def swift_object_url
url = ENV.fetch('SWIFT_OBJECT_URL', nil)
return if url.blank? || !url.start_with?('https://')
url += '/' unless url.end_with?('/')
url
end
def uri_from_configuration_and_string(host_string)
Addressable::URI.parse("#{host_protocol}://#{host_string}").tap do |uri|
uri.path += '/' unless uri.path.blank? || uri.path.end_with?('/')