Skip to content

Commit

Permalink
Fix invalid Content-Type header for WebP images (#26773)
Browse files Browse the repository at this point in the history
  • Loading branch information
c960657 committed Sep 4, 2023
1 parent 1f92436 commit ea31929
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions config/initializers/mime_types.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true

# Be sure to restart your server when you modify this file.

Mime::Type.register 'application/json', :json, %w(text/x-json application/jsonrequest application/jrd+json application/activity+json application/ld+json)
Mime::Type.register 'text/xml', :xml, %w(application/xml application/atom+xml application/xrd+xml)

# WebP is not defined in Rack 2.2.
Rack::Mime::MIME_TYPES['.webp'] = 'image/webp'
3 changes: 3 additions & 0 deletions spec/models/media_attachment_spec.rb
Expand Up @@ -105,6 +105,9 @@

# sets file extension
expect(media.file_file_name).to end_with extension

# Rack::Mime (used by PublicFileServerMiddleware) recognizes file extension
expect(Rack::Mime.mime_type(extension, nil)).to eq content_type
end

it 'saves media attachment with correct size metadata' do
Expand Down

0 comments on commit ea31929

Please sign in to comment.