diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b671c5..d58625e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md
@@ -1,3 +1,17 @@ +# 1.0.3 + +* Add application/manifest+json lookup by extension. +* Add application/toml mimeType lookup by extension. +* Add audio/aac mimeType lookup by header bytes. +* Add audio/mpeg mimeType lookup by header bytes. +* Add audio/ogg mimeType lookup by header bytes. +* Add audio/weba mimeType lookup by header bytes. +* Add font/woff2 lookup by extension and header bytes. +* Add image/avif mimeType lookup by extension. +* Add image/heic mimeType lookup by extension. +* Add image/heif mimeType lookup by extension. +* Change audio/x-aac to audio/aac when detected by extension. + # 1.0.2 * Add audio/x-aiff mimeType lookup by header bytes.
diff --git a/lib/src/default_extension_map.dart b/lib/src/default_extension_map.dart index 84aa9ae..e66733f 100644 --- a/lib/src/default_extension_map.dart +++ b/lib/src/default_extension_map.dart
@@ -10,7 +10,7 @@ '3gp': 'video/3gpp', '7z': 'application/x-7z-compressed', 'aab': 'application/x-authorware-bin', - 'aac': 'audio/x-aac', + 'aac': 'audio/aac', 'aam': 'application/x-authorware-map', 'aas': 'application/x-authorware-seg', 'abw': 'application/x-abiword', @@ -48,6 +48,7 @@ 'atx': 'application/vnd.antix.game-component', 'au': 'audio/basic', 'avi': 'video/x-msvideo', + 'avif': 'image/avif', 'aw': 'application/applixware', 'azf': 'application/vnd.airzip.filesecure.azf', 'azs': 'application/vnd.airzip.filesecure.azs', @@ -308,6 +309,8 @@ 'hal': 'application/vnd.hal+xml', 'hbci': 'application/vnd.hbci', 'hdf': 'application/x-hdf', + 'heic': 'image/heic', + 'heif': 'image/heif', 'hh': 'text/x-c', 'hlp': 'application/winhlp', 'hpgl': 'application/vnd.hp-hpgl', @@ -803,6 +806,8 @@ 'tif': 'image/tiff', 'tiff': 'image/tiff', 'tmo': 'application/vnd.tmobile-livetv', + // Source: https://toml.io/en/v1.0.0#mime-type + 'toml': 'application/toml', 'torrent': 'application/x-bittorrent', 'tpl': 'application/vnd.groove-tool-template', 'tpt': 'application/vnd.trid.tpt', @@ -893,6 +898,8 @@ 'wdp': 'image/vnd.ms-photo', 'weba': 'audio/webm', 'webm': 'video/webm', + // Source: https://w3c.github.io/manifest/#media-type-registration + 'webmanifest': 'application/manifest+json', 'webp': 'image/webp', 'wg': 'application/vnd.pmi.widget', 'wgt': 'application/widget', @@ -909,6 +916,7 @@ 'wmx': 'video/x-ms-wmx', 'wmz': 'application/x-ms-wmz', 'woff': 'application/x-font-woff', + 'woff2': 'font/woff2', 'wpd': 'application/vnd.wordperfect', 'wpl': 'application/vnd.ms-wpl', 'wps': 'application/vnd.ms-works',
diff --git a/lib/src/magic_number.dart b/lib/src/magic_number.dart index 0cb5a8d..ee3de31 100644 --- a/lib/src/magic_number.dart +++ b/lib/src/magic_number.dart
@@ -107,6 +107,12 @@ MagicNumber('image/png', [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]), MagicNumber('image/tiff', [0x49, 0x49, 0x2A, 0x00]), MagicNumber('image/tiff', [0x4D, 0x4D, 0x00, 0x2A]), + MagicNumber('audio/aac', [0xFF, 0xF1]), + MagicNumber('audio/aac', [0xFF, 0xF9]), + MagicNumber('audio/weba', [0x1A, 0x45, 0xDF, 0xA3]), + MagicNumber('audio/mpeg', [0x49, 0x44, 0x33]), + MagicNumber('audio/mpeg', [0xFF, 0xFB]), + MagicNumber('audio/ogg', [0x4F, 0x70, 0x75]), MagicNumber('video/mp4', [ 0x00, 0x00, @@ -167,5 +173,7 @@ 0xFF, 0xFF, 0xFF - ]) + ]), + + MagicNumber('font/woff2', [0x77, 0x4f, 0x46, 0x32]), ];
diff --git a/pubspec.yaml b/pubspec.yaml index af9210b..b675981 100644 --- a/pubspec.yaml +++ b/pubspec.yaml
@@ -1,5 +1,5 @@ name: mime -version: 1.0.2 +version: 1.0.3 description: >- Utilities for handling media (MIME) types, including determining a type from a file extension and file contents.
diff --git a/test/mime_type_test.dart b/test/mime_type_test.dart index b5f037d..e99214a 100644 --- a/test/mime_type_test.dart +++ b/test/mime_type_test.dart
@@ -41,8 +41,12 @@ _expectMimeType('file.tiff', 'image/tiff'); _expectMimeType('file.tif', 'image/tiff'); _expectMimeType('file.webp', 'image/webp'); + _expectMimeType('file.mp3', 'audio/mpeg'); + _expectMimeType('file.aac', 'audio/aac'); + _expectMimeType('file.ogg', 'audio/ogg'); _expectMimeType('file.aiff', 'audio/x-aiff'); _expectMimeType('file.m4a', 'audio/mp4'); + _expectMimeType('file.toml', 'application/toml'); }); test('unknown-mime-type', () { @@ -104,6 +108,12 @@ 0x42, 0x50 ]); + _expectMimeType('file', 'audio/mpeg', + headerBytes: [0x49, 0x44, 0x33, 0x0D, 0x0A, 0x1A, 0x0A]); + _expectMimeType('file', 'audio/aac', + headerBytes: [0xFF, 0xF1, 0x0D, 0x0A, 0x1A, 0x0A]); + _expectMimeType('file', 'audio/ogg', + headerBytes: [0x4F, 0x70, 0x75, 0x0D, 0x0A, 0x1A, 0x0A]); _expectMimeType('file', 'audio/x-aiff', headerBytes: [ 0x46, 0x4F,