// SPDX-License-Identifier: AGPL-3.0-or-later package directory import "testing" func TestSniffMime(t *testing.T) { cases := []struct{ head, name, want string }{ {``, "drawing.excalidraw.svg", "image/svg+xml"}, {``, "d.svg", "image/svg+xml"}, {``, "d.xml", "text/xml; charset=utf-8"}, {``, "evil.svg", "text/html; charset=utf-8"}, {"\x89PNG\r\n\x1a\n", "a.png", "image/png"}, } for _, c := range cases { if got := sniffMime([]byte(c.head), c.name); got != c.want { t.Errorf("sniffMime(%q, %q) = %q, want %q", c.head, c.name, got, c.want) } } }