Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow symbols to be passed for extension aliases

  • Loading branch information...
commit 4d5266e2706195888c9f72fdc9ebde22f89a08df 1 parent 4f35d5a
Justin Campbell justincampbell authored
2  actionpack/lib/action_dispatch/http/mime_type.rb
View
@@ -103,7 +103,7 @@ def register(string, symbol, mime_type_synonyms = [], extension_synonyms = [], s
SET << Mime.const_get(symbol.to_s.upcase)
([string] + mime_type_synonyms).each { |str| LOOKUP[str] = SET.last } unless skip_lookup
- ([symbol.to_s] + extension_synonyms).each { |ext| EXTENSION_LOOKUP[ext] = SET.last }
+ ([symbol] + extension_synonyms).each { |ext| EXTENSION_LOOKUP[ext.to_s] = SET.last }
end
def parse(accept_header)
11 actionpack/test/dispatch/mime_type_test.rb
View
@@ -95,6 +95,17 @@ class MimeTypeTest < ActiveSupport::TestCase
end
end
+ test "custom type with extension aliases" do
+ begin
+ Mime::Type.register "text/foobar", :foobar, [], [:foo, "bar"]
+ %w[foobar foo bar].each do |extension|
+ assert_equal Mime::FOOBAR, Mime::EXTENSION_LOOKUP[extension]
+ end
+ ensure
+ Mime::Type.unregister(:FOOBAR)
+ end
+ end
+
test "type should be equal to symbol" do
assert_equal Mime::HTML, 'application/xhtml+xml'
assert_equal Mime::HTML, :html
Please sign in to comment.
Something went wrong with that request. Please try again.