Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/mime/type/columnar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions test/test_mime_types_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading