jellyfin/tests/Jellyfin.Model.Tests/Net/MimeTypesTests.cs

172 lines
7.5 KiB
C#
Raw Normal View History

using MediaBrowser.Model.Net;
using Xunit;
namespace Jellyfin.Model.Tests.Net
{
public class MimeTypesTests
{
[Theory]
Add missing MIME types for comicbook formats (#11010) * Correct MIME types for comicbook file extensions cb7, cba, cbr, cbt and cbz all refer to different types of digital comicbooks. The last letter of the extension indicates the compression algorithm that was used: 7zip, arc, rar, tar or zip. All these filetypes used to have the `application/x-cbr` MIME type assigned to them. However, that has since been deprecated and was replaced with - `application/vnd.comicbook-rar` for rar compressed files and - `application/vnd.comicbook+zip` for rar compressed files. Only these two are officially listed by IANA https://www.iana.org/assignments/media-types/application/vnd.comicbook+zip . cbr and cbz are by far the most common file extensions for comicbooks. There's no official MIME type for cb7, cba or cbt files. However, with rar being a proprietary compression algorithm, FOSS applications will often refuse to handle files that identify themselves as `application/x-cbr`, so I decided to assign extension specific MIME types to them. I've seen these being used by other applications, specifically comic book readers. I've read through the docs on iana.org, but haven't figured out why they chose `-rar`, but `+zip`. * Add conversions from MIME type to file extensions for comicbook formats cb7, cba, cbr, cbt and cbz all refer to different types of digital comicbooks. The last letter of the extension indicates the compression algorithm that was used: 7zip, arc, rar, tar or zip. All these filetypes used to have the `application/x-cbr` MIME type assigned to them. However, that has since been deprecated and was replaced with - `application/vnd.comicbook-rar` for rar compressed files and - `application/vnd.comicbook+zip` for rar compressed files. Only these two are officially listed by IANA https://www.iana.org/assignments/media-types/application/vnd.comicbook+zip . cbr and cbz are by far the most common file extensions for comicbooks. There's no official MIME type for cb7, cba or cbt files. However, with rar being a proprietary compression algorithm, FOSS applications will often refuse to handle files that identify themselves as `application/x-cbr`, so I decided to assign extension specific MIME types to them. I've seen these being used by other applications, specifically comic book readers. * Update CONTRIBUTORS.md
2024-02-15 17:15:14 -05:00
[InlineData(".cb7", "application/x-cb7")]
[InlineData(".cba", "application/x-cba")]
[InlineData(".cbr", "application/vnd.comicbook-rar")]
[InlineData(".cbt", "application/x-cbt")]
[InlineData(".cbz", "application/vnd.comicbook+zip")]
[InlineData(".dll", "application/octet-stream")]
[InlineData(".log", "text/plain")]
[InlineData(".srt", "application/x-subrip")]
[InlineData(".html", "text/html; charset=UTF-8")]
[InlineData(".htm", "text/html; charset=UTF-8")]
[InlineData(".7z", "application/x-7z-compressed")]
[InlineData(".azw", "application/vnd.amazon.ebook")]
[InlineData(".azw3", "application/vnd.amazon.ebook")]
[InlineData(".eot", "application/vnd.ms-fontobject")]
[InlineData(".epub", "application/epub+zip")]
[InlineData(".json", "application/json")]
[InlineData(".mobi", "application/x-mobipocket-ebook")]
[InlineData(".opf", "application/oebps-package+xml")]
[InlineData(".pdf", "application/pdf")]
[InlineData(".rar", "application/vnd.rar")]
[InlineData(".ttml", "application/ttml+xml")]
[InlineData(".wasm", "application/wasm")]
[InlineData(".xml", "application/xml")]
[InlineData(".zip", "application/zip")]
[InlineData(".bmp", "image/bmp")]
[InlineData(".gif", "image/gif")]
[InlineData(".ico", "image/vnd.microsoft.icon")]
[InlineData(".jpg", "image/jpeg")]
[InlineData(".jpeg", "image/jpeg")]
[InlineData(".png", "image/png")]
[InlineData(".svg", "image/svg+xml")]
[InlineData(".svgz", "image/svg+xml")]
[InlineData(".tbn", "image/jpeg")]
[InlineData(".tif", "image/tiff")]
[InlineData(".tiff", "image/tiff")]
[InlineData(".webp", "image/webp")]
[InlineData(".ttf", "font/ttf")]
[InlineData(".woff", "font/woff")]
[InlineData(".woff2", "font/woff2")]
[InlineData(".ass", "text/x-ssa")]
[InlineData(".ssa", "text/x-ssa")]
[InlineData(".css", "text/css")]
[InlineData(".csv", "text/csv")]
[InlineData(".edl", "text/plain")]
[InlineData(".txt", "text/plain")]
[InlineData(".vtt", "text/vtt")]
[InlineData(".3gp", "video/3gpp")]
[InlineData(".3g2", "video/3gpp2")]
[InlineData(".asf", "video/x-ms-asf")]
[InlineData(".avi", "video/x-msvideo")]
[InlineData(".flv", "video/x-flv")]
[InlineData(".mp4", "video/mp4")]
[InlineData(".m4v", "video/x-m4v")]
[InlineData(".mpegts", "video/mp2t")]
[InlineData(".mpg", "video/mpeg")]
[InlineData(".mkv", "video/x-matroska")]
[InlineData(".mov", "video/quicktime")]
[InlineData(".ogv", "video/ogg")]
[InlineData(".ts", "video/mp2t")]
[InlineData(".webm", "video/webm")]
[InlineData(".wmv", "video/x-ms-wmv")]
[InlineData(".aac", "audio/aac")]
[InlineData(".ac3", "audio/ac3")]
[InlineData(".ape", "audio/x-ape")]
[InlineData(".dsf", "audio/dsf")]
[InlineData(".dsp", "audio/dsp")]
[InlineData(".flac", "audio/flac")]
[InlineData(".m4a", "audio/mp4")]
2024-02-10 23:39:30 -05:00
[InlineData(".m4b", "audio/mp4")]
[InlineData(".mid", "audio/midi")]
[InlineData(".midi", "audio/midi")]
[InlineData(".mp3", "audio/mpeg")]
[InlineData(".oga", "audio/ogg")]
[InlineData(".ogg", "audio/ogg")]
[InlineData(".opus", "audio/ogg")]
[InlineData(".vorbis", "audio/vorbis")]
[InlineData(".wav", "audio/wav")]
[InlineData(".webma", "audio/webm")]
[InlineData(".wma", "audio/x-ms-wma")]
[InlineData(".wv", "audio/x-wavpack")]
[InlineData(".xsp", "audio/xsp")]
public void GetMimeType_Valid_ReturnsCorrectResult(string input, string expectedResult)
{
Assert.Equal(expectedResult, MimeTypes.GetMimeType(input, null));
}
[Theory]
[InlineData("application/epub+zip", ".epub")]
[InlineData("application/json", ".json")]
[InlineData("application/oebps-package+xml", ".opf")]
[InlineData("application/pdf", ".pdf")]
[InlineData("application/ttml+xml", ".ttml")]
[InlineData("application/vnd.amazon.ebook", ".azw")]
Add missing MIME types for comicbook formats (#11010) * Correct MIME types for comicbook file extensions cb7, cba, cbr, cbt and cbz all refer to different types of digital comicbooks. The last letter of the extension indicates the compression algorithm that was used: 7zip, arc, rar, tar or zip. All these filetypes used to have the `application/x-cbr` MIME type assigned to them. However, that has since been deprecated and was replaced with - `application/vnd.comicbook-rar` for rar compressed files and - `application/vnd.comicbook+zip` for rar compressed files. Only these two are officially listed by IANA https://www.iana.org/assignments/media-types/application/vnd.comicbook+zip . cbr and cbz are by far the most common file extensions for comicbooks. There's no official MIME type for cb7, cba or cbt files. However, with rar being a proprietary compression algorithm, FOSS applications will often refuse to handle files that identify themselves as `application/x-cbr`, so I decided to assign extension specific MIME types to them. I've seen these being used by other applications, specifically comic book readers. I've read through the docs on iana.org, but haven't figured out why they chose `-rar`, but `+zip`. * Add conversions from MIME type to file extensions for comicbook formats cb7, cba, cbr, cbt and cbz all refer to different types of digital comicbooks. The last letter of the extension indicates the compression algorithm that was used: 7zip, arc, rar, tar or zip. All these filetypes used to have the `application/x-cbr` MIME type assigned to them. However, that has since been deprecated and was replaced with - `application/vnd.comicbook-rar` for rar compressed files and - `application/vnd.comicbook+zip` for rar compressed files. Only these two are officially listed by IANA https://www.iana.org/assignments/media-types/application/vnd.comicbook+zip . cbr and cbz are by far the most common file extensions for comicbooks. There's no official MIME type for cb7, cba or cbt files. However, with rar being a proprietary compression algorithm, FOSS applications will often refuse to handle files that identify themselves as `application/x-cbr`, so I decided to assign extension specific MIME types to them. I've seen these being used by other applications, specifically comic book readers. * Update CONTRIBUTORS.md
2024-02-15 17:15:14 -05:00
[InlineData("application/vnd.comicbook-rar", ".cbr")]
[InlineData("application/vnd.comicbook+zip", ".cbz")]
[InlineData("application/vnd.ms-fontobject", ".eot")]
[InlineData("application/vnd.rar", ".rar")]
[InlineData("application/wasm", ".wasm")]
[InlineData("application/x-7z-compressed", ".7z")]
Add missing MIME types for comicbook formats (#11010) * Correct MIME types for comicbook file extensions cb7, cba, cbr, cbt and cbz all refer to different types of digital comicbooks. The last letter of the extension indicates the compression algorithm that was used: 7zip, arc, rar, tar or zip. All these filetypes used to have the `application/x-cbr` MIME type assigned to them. However, that has since been deprecated and was replaced with - `application/vnd.comicbook-rar` for rar compressed files and - `application/vnd.comicbook+zip` for rar compressed files. Only these two are officially listed by IANA https://www.iana.org/assignments/media-types/application/vnd.comicbook+zip . cbr and cbz are by far the most common file extensions for comicbooks. There's no official MIME type for cb7, cba or cbt files. However, with rar being a proprietary compression algorithm, FOSS applications will often refuse to handle files that identify themselves as `application/x-cbr`, so I decided to assign extension specific MIME types to them. I've seen these being used by other applications, specifically comic book readers. I've read through the docs on iana.org, but haven't figured out why they chose `-rar`, but `+zip`. * Add conversions from MIME type to file extensions for comicbook formats cb7, cba, cbr, cbt and cbz all refer to different types of digital comicbooks. The last letter of the extension indicates the compression algorithm that was used: 7zip, arc, rar, tar or zip. All these filetypes used to have the `application/x-cbr` MIME type assigned to them. However, that has since been deprecated and was replaced with - `application/vnd.comicbook-rar` for rar compressed files and - `application/vnd.comicbook+zip` for rar compressed files. Only these two are officially listed by IANA https://www.iana.org/assignments/media-types/application/vnd.comicbook+zip . cbr and cbz are by far the most common file extensions for comicbooks. There's no official MIME type for cb7, cba or cbt files. However, with rar being a proprietary compression algorithm, FOSS applications will often refuse to handle files that identify themselves as `application/x-cbr`, so I decided to assign extension specific MIME types to them. I've seen these being used by other applications, specifically comic book readers. * Update CONTRIBUTORS.md
2024-02-15 17:15:14 -05:00
[InlineData("application/x-cb7", ".cb7")]
[InlineData("application/x-cba", ".cba")]
[InlineData("application/x-cbr", ".cbr")]
[InlineData("application/x-cbt", ".cbt")]
[InlineData("application/x-cbz", ".cbz")]
[InlineData("application/x-javascript", ".js")]
[InlineData("application/x-mobipocket-ebook", ".mobi")]
[InlineData("application/x-mpegURL", ".m3u8")]
[InlineData("application/x-subrip", ".srt")]
[InlineData("application/xml", ".xml")]
[InlineData("application/zip", ".zip")]
[InlineData("audio/aac", ".aac")]
[InlineData("audio/ac3", ".ac3")]
[InlineData("audio/dsf", ".dsf")]
[InlineData("audio/dsp", ".dsp")]
[InlineData("audio/flac", ".flac")]
[InlineData("audio/m4b", ".m4b")]
[InlineData("audio/mp4", ".m4a")]
[InlineData("audio/vorbis", ".vorbis")]
[InlineData("audio/wav", ".wav")]
[InlineData("audio/x-aac", ".aac")]
[InlineData("audio/x-ape", ".ape")]
[InlineData("audio/x-ms-wma", ".wma")]
[InlineData("audio/x-wavpack", ".wv")]
[InlineData("audio/xsp", ".xsp")]
[InlineData("font/ttf", ".ttf")]
[InlineData("font/woff", ".woff")]
[InlineData("font/woff2", ".woff2")]
[InlineData("image/bmp", ".bmp")]
[InlineData("image/gif", ".gif")]
[InlineData("image/jpeg", ".jpg")]
[InlineData("image/png", ".png")]
[InlineData("image/svg+xml", ".svg")]
2023-01-10 11:15:21 -05:00
[InlineData("image/tiff", ".tiff")]
[InlineData("image/vnd.microsoft.icon", ".ico")]
[InlineData("image/webp", ".webp")]
2023-01-10 11:15:21 -05:00
[InlineData("image/x-icon", ".ico")]
[InlineData("image/x-png", ".png")]
[InlineData("text/css", ".css")]
[InlineData("text/csv", ".csv")]
[InlineData("text/plain", ".txt")]
[InlineData("text/rtf", ".rtf")]
[InlineData("text/vtt", ".vtt")]
[InlineData("text/x-ssa", ".ssa")]
[InlineData("video/3gpp", ".3gp")]
[InlineData("video/3gpp2", ".3g2")]
[InlineData("video/mp2t", ".ts")]
[InlineData("video/mp4", ".mp4")]
[InlineData("video/ogg", ".ogv")]
[InlineData("video/quicktime", ".mov")]
[InlineData("video/vnd.mpeg.dash.mpd", ".mpd")]
[InlineData("video/webm", ".webm")]
[InlineData("video/x-flv", ".flv")]
[InlineData("video/x-m4v", ".m4v")]
[InlineData("video/x-matroska", ".mkv")]
[InlineData("video/x-ms-asf", ".asf")]
[InlineData("video/x-ms-wmv", ".wmv")]
[InlineData("video/x-msvideo", ".avi")]
public void ToExtension_Valid_ReturnsCorrectResult(string input, string expectedResult)
{
Assert.Equal(expectedResult, MimeTypes.ToExtension(input));
}
}
}