diff --git a/lib/mime/type/columnar.rb b/lib/mime/type/columnar.rb index 7006fab..2d3fa43 100644 --- a/lib/mime/type/columnar.rb +++ b/lib/mime/type/columnar.rb @@ -54,7 +54,7 @@ def encode_with(coder) # :nodoc: end def update_sort_priority - if @container.__fully_loaded? + if @container.__fully_loaded? || @__sort_priority.nil? super else obsolete = (@__sort_priority & (1 << 7)) != 0 diff --git a/test/test_mime_types_class.rb b/test/test_mime_types_class.rb index 05494dd..4904c4c 100644 --- a/test/test_mime_types_class.rb +++ b/test/test_mime_types_class.rb @@ -103,6 +103,13 @@ def setup assert_includes MIME::Types.type_for("xtxt"), "text/plain" end + it "sorts correctly after modifying type extensions" do + a = MIME::Types["text/plain"].first + b = MIME::Types["image/jpeg"].first + a.add_extensions("sort-test") + assert_equal 2, [a, b].sort.length + end + it "handles newline characters correctly" do assert_includes MIME::Types.type_for("test.pdf\n.txt"), "text/plain" assert_includes MIME::Types.type_for("test.txt\n.pdf"), "application/pdf"