Skip to content

Commit

Permalink
Change Content-Security-Policy to be tighter on media paths (mastodon…
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire committed Oct 23, 2023
1 parent bcae744 commit c3e0eb3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion config/initializers/content_security_policy.rb
Expand Up @@ -5,7 +5,11 @@
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy

def host_to_url(str)
"http#{Rails.configuration.x.use_https ? 's' : ''}://#{str.split('/').first}" if str.present?
return if str.blank?

uri = Addressable::URI.parse("http#{Rails.configuration.x.use_https ? 's' : ''}://#{str}")
uri.path += '/' unless uri.path.blank? || uri.path.end_with?('/')
uri.to_s
end

base_host = Rails.configuration.x.web_domain
Expand Down

0 comments on commit c3e0eb3

Please sign in to comment.