This commit is contained in:
Thibault Deckers 2023-01-03 20:05:30 +01:00
parent 44eb9c7fdf
commit c693055721
2 changed files with 16 additions and 9 deletions

View file

@ -60,6 +60,7 @@ class MimeTypes {
static const mkv = 'video/mkv'; static const mkv = 'video/mkv';
static const mkvX = 'video/x-matroska'; static const mkvX = 'video/x-matroska';
static const mov = 'video/quicktime'; static const mov = 'video/quicktime';
static const movX = 'video/x-quicktime';
static const mp2p = 'video/mp2p'; static const mp2p = 'video/mp2p';
static const mp2t = 'video/mp2t'; // .m2ts, .ts static const mp2t = 'video/mp2t'; // .m2ts, .ts
static const mp2ts = 'video/mp2ts'; // .ts (prefer `mp2t` when possible) static const mp2ts = 'video/mp2ts'; // .ts (prefer `mp2t` when possible)
@ -89,7 +90,7 @@ class MimeTypes {
static const Set<String> _knownOpaqueImages = {jpeg}; static const Set<String> _knownOpaqueImages = {jpeg};
static const Set<String> _knownVideos = {v3gpp, asf, avi, aviMSVideo, aviVnd, aviXMSVideo, flv, flvX, mkv, mkvX, mov, mp2p, mp2t, mp2ts, mp4, mpeg, ogv, realVideo, webm, wmv}; static const Set<String> _knownVideos = {v3gpp, asf, avi, aviMSVideo, aviVnd, aviXMSVideo, flv, flvX, mkv, mkvX, mov, movX, mp2p, mp2t, mp2ts, mp4, mpeg, ogv, realVideo, webm, wmv};
static final Set<String> knownMediaTypes = { static final Set<String> knownMediaTypes = {
anyImage, anyImage,
@ -107,30 +108,35 @@ class MimeTypes {
static bool isVisual(String mimeType) => isImage(mimeType) || isVideo(mimeType); static bool isVisual(String mimeType) => isImage(mimeType) || isVideo(mimeType);
static bool refersToSameType(String a, b) { static String _collapsedType(String mimeType) {
switch (a) { switch (mimeType) {
case avi: case avi:
case aviMSVideo: case aviMSVideo:
case aviVnd: case aviVnd:
case aviXMSVideo: case aviXMSVideo:
return [avi, aviVnd].contains(b); return avi;
case bmp: case bmp:
case bmpX: case bmpX:
return [bmp, bmpX].contains(b); return bmp;
case flv: case flv:
case flvX: case flvX:
return [flv, flvX].contains(b); return flv;
case heic: case heic:
case heif: case heif:
return [heic, heif].contains(b); return heic;
case mov:
case movX:
return mov;
case psdVnd: case psdVnd:
case psdX: case psdX:
return [psdVnd, psdX].contains(b); return psdVnd;
default: default:
return a == b; return mimeType;
} }
} }
static bool refersToSameType(String a, b) => _collapsedType(a) == _collapsedType(b);
static String? forExtension(String extension) { static String? forExtension(String extension) {
switch (extension) { switch (extension) {
case '.jpg': case '.jpg':

View file

@ -8,6 +8,7 @@ class MimeUtils {
case MimeTypes.ico: case MimeTypes.ico:
return 'ICO'; return 'ICO';
case MimeTypes.mov: case MimeTypes.mov:
case MimeTypes.movX:
return 'MOV'; return 'MOV';
case MimeTypes.psdVnd: case MimeTypes.psdVnd:
case MimeTypes.psdX: case MimeTypes.psdX: