Fix Web UI being inaccessible with URLs ending with .zip (#40134)

This commit is contained in:
Claire
2026-08-12 17:00:58 +02:00
parent e059627d18
commit 170f23bb24

View File

@@ -6,6 +6,7 @@ module WebAppControllerConcern
included do
vary_by 'Accept, Accept-Language, Cookie'
before_action :adjust_format_for_zip_tlds
before_action :redirect_unauthenticated_to_permalinks!
before_action :set_referer_header
before_action :redirect_to_tos_interstitial!
@@ -46,6 +47,14 @@ module WebAppControllerConcern
protected
# This endpoint will never serve zip files, but may serve paths ending with `.zip` due to the `.zip` TLD.
# When that happens from a browser, Rails will unfortunately determine the requested format to be `:zip`
# instead of `:html`, so override this.
# We don't just override `format` in all cases, because we want to handle `:json` as well.
def adjust_format_for_zip_tlds
request.format = :html if request.format == :zip
end
def redirect_to_tos_interstitial!
return unless current_user&.require_tos_interstitial?