Explorar el Código

fix: add mjs mime type (fix: #4098) (#4108)

Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
Autumn Meadow hace 3 años
padre
commit
45c4525386
Se han modificado 2 ficheros con 10 adiciones y 0 borrados
  1. 6 0
      .changes/mjs-mime-type.md
  2. 4 0
      core/tauri-runtime/src/http/mime_type.rs

+ 6 - 0
.changes/mjs-mime-type.md

@@ -0,0 +1,6 @@
+---
+"tauri": patch
+"tauri-runtime": patch
+---
+
+Fix `.mjs` not being recognised as a file extension for JavaScript files (`text/javascript`).

+ 4 - 0
core/tauri-runtime/src/http/mime_type.rs

@@ -53,6 +53,7 @@ impl MimeType {
       Some("js") => Self::Js,
       Some("json") => Self::Json,
       Some("jsonld") => Self::Jsonld,
+      Some("mjs") => Self::Js,
       Some("rtf") => Self::Rtf,
       Some("svg") => Self::Svg,
       Some("mp4") => Self::Mp4,
@@ -115,6 +116,9 @@ mod tests {
     let jsonld: String = MimeType::parse_from_uri("https:/example.com/hello.jsonld").to_string();
     assert_eq!(jsonld, String::from("application/ld+json"));
 
+    let mjs: String = MimeType::parse_from_uri("https://example.com/bundled.mjs").to_string();
+    assert_eq!(mjs, String::from("text/javascript"));
+
     let rtf: String = MimeType::parse_from_uri("https://example.com/document.rtf").to_string();
     assert_eq!(rtf, String::from("application/rtf"));