@@ -18,10 +18,11 @@ pub enum MimeType {
1818 Js ,
1919 Json ,
2020 Jsonld ,
21+ Mp4 ,
2122 OctetStream ,
2223 Rtf ,
2324 Svg ,
24- Mp4 ,
25+ Txt ,
2526}
2627
2728impl std:: fmt:: Display for MimeType {
@@ -34,10 +35,11 @@ impl std::fmt::Display for MimeType {
3435 MimeType :: Js => "text/javascript" ,
3536 MimeType :: Json => "application/json" ,
3637 MimeType :: Jsonld => "application/ld+json" ,
38+ MimeType :: Mp4 => "video/mp4" ,
3739 MimeType :: OctetStream => "application/octet-stream" ,
3840 MimeType :: Rtf => "application/rtf" ,
3941 MimeType :: Svg => "image/svg+xml" ,
40- MimeType :: Mp4 => "video/mp4" ,
42+ MimeType :: Txt => MIMETYPE_PLAIN ,
4143 } ;
4244 write ! ( f, "{mime}" )
4345 }
@@ -62,9 +64,10 @@ impl MimeType {
6264 Some ( "json" ) => Self :: Json ,
6365 Some ( "jsonld" ) => Self :: Jsonld ,
6466 Some ( "mjs" ) => Self :: Js ,
67+ Some ( "mp4" ) => Self :: Mp4 ,
6568 Some ( "rtf" ) => Self :: Rtf ,
6669 Some ( "svg" ) => Self :: Svg ,
67- Some ( "mp4 " ) => Self :: Mp4 ,
70+ Some ( "txt " ) => Self :: Txt ,
6871 // Assume HTML when a TLD is found for eg. `wry:://tauri.app` | `wry://hello.com`
6972 Some ( _) => fallback,
7073 // using octet stream according to this:
@@ -133,14 +136,17 @@ mod tests {
133136 let mjs: String = MimeType :: parse_from_uri ( "https://example.com/bundled.mjs" ) . to_string ( ) ;
134137 assert_eq ! ( mjs, String :: from( "text/javascript" ) ) ;
135138
139+ let mp4: String = MimeType :: parse_from_uri ( "https://example.com/video.mp4" ) . to_string ( ) ;
140+ assert_eq ! ( mp4, String :: from( "video/mp4" ) ) ;
141+
136142 let rtf: String = MimeType :: parse_from_uri ( "https://example.com/document.rtf" ) . to_string ( ) ;
137143 assert_eq ! ( rtf, String :: from( "application/rtf" ) ) ;
138144
139145 let svg: String = MimeType :: parse_from_uri ( "https://example.com/picture.svg" ) . to_string ( ) ;
140146 assert_eq ! ( svg, String :: from( "image/svg+xml" ) ) ;
141147
142- let mp4 : String = MimeType :: parse_from_uri ( "https://example.com/video.mp4 " ) . to_string ( ) ;
143- assert_eq ! ( mp4 , String :: from( "video/mp4 " ) ) ;
148+ let txt : String = MimeType :: parse_from_uri ( "https://example.com/file.txt " ) . to_string ( ) ;
149+ assert_eq ! ( txt , String :: from( "text/plain " ) ) ;
144150
145151 let custom_scheme = MimeType :: parse_from_uri ( "wry://tauri.app" ) . to_string ( ) ;
146152 assert_eq ! ( custom_scheme, String :: from( "text/html" ) ) ;
0 commit comments