Skip to content
Merged
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.ex
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ defmodule MIME do
"image/gif" => ["gif"],
"image/heic" => ["heic"],
"image/heif" => ["heif"],
"image/jp2" => [".jp2"],
"image/jp2" => ["jp2"],
"image/jpeg" => ["jpg", "jpeg"],
"image/jxl" => ["jxl"],
"image/png" => ["png"],
Expand Down
7 changes: 7 additions & 0 deletions test/mime_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ defmodule MIMETest do
assert extensions("application/vnd.custom+xml/extrainvalid") == []
end

test "extensions must not lead with a dot" do
for {type, exts} <- known_types(), ext <- exts do
expected = String.replace_leading(ext, ".", "")
assert expected == ext, "type '#{type}' includes '#{ext}', replace it with '#{expected}'."
end
end

test "type/1" do
assert type("json") == "application/json"
assert type("foo") == "application/octet-stream"
Expand Down
Loading