| 1 | module mime |
| 2 | |
| 3 | fn test_mime() { |
| 4 | assert get_complete_mime_type('application/json') == MimeType{ |
| 5 | source: 'iana' |
| 6 | extensions: ['json', 'map'] |
| 7 | compressible: true |
| 8 | charset: 'UTF-8' |
| 9 | } |
| 10 | assert get_mime_type('json') == 'application/json' |
| 11 | assert get_content_type('application/json') == 'application/json; charset=utf-8' |
| 12 | assert get_default_ext('application/json') == 'json' |
| 13 | |
| 14 | assert get_complete_mime_type('text/markdown') == MimeType{ |
| 15 | source: 'iana' |
| 16 | extensions: ['md', 'markdown'] |
| 17 | compressible: true |
| 18 | charset: '' |
| 19 | } |
| 20 | assert get_mime_type('md') == 'text/markdown' |
| 21 | assert get_content_type('text/markdown') == 'text/markdown; charset=utf-8' |
| 22 | assert get_default_ext('text/markdown') == 'md' |
| 23 | |
| 24 | assert exists('application/json') == true |
| 25 | assert exists('udfsbsfib') == false |
| 26 | |
| 27 | assert get_default_ext('application/1d-interleaved-parityfec') == '' // valid mime type without associated extension |
| 28 | assert get_default_ext('invalid mime type') == '' // invalid mime type |
| 29 | } |
| 30 | |