From 665651d428d0f8e239821f3245d6736467ddfea4 Mon Sep 17 00:00:00 2001 From: Ilia Naryzhny Date: Tue, 12 Mar 2024 09:49:33 -0700 Subject: [PATCH] Add .cjs and .mjs to MIME types. Fix #25 --- .../main/java/org/orienteer/jnpm/JNPMUtils.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/jnpm/src/main/java/org/orienteer/jnpm/JNPMUtils.java b/jnpm/src/main/java/org/orienteer/jnpm/JNPMUtils.java index 15a7e0e..4d83afd 100644 --- a/jnpm/src/main/java/org/orienteer/jnpm/JNPMUtils.java +++ b/jnpm/src/main/java/org/orienteer/jnpm/JNPMUtils.java @@ -233,6 +233,8 @@ public static Map toMap(K... items) { { MIME_TYPES_MAPPING.put("json", "application/json"); MIME_TYPES_MAPPING.put("js", "text/javascript"); + MIME_TYPES_MAPPING.put("cjs", "application/node"); + MIME_TYPES_MAPPING.put("mjs", "text/javascript;goal=Module"); MIME_TYPES_MAPPING.put("css", "text/css"); MIME_TYPES_MAPPING.put("htm", "text/html"); MIME_TYPES_MAPPING.put("html", "text/html"); @@ -286,18 +288,6 @@ public static String fileNameToMimeType(String fileName) { int indx = fileName.lastIndexOf('.'); if(indx>=0) extension = fileName.substring(indx+1).toLowerCase(); - switch (extension) { - case "json": - return "application/json"; - case "js": - return "text/javascript"; - case "css": - return "text/css"; - case "htm": - case "html": - case "xhtml": - return "text/html"; - } return MIME_TYPES_MAPPING.getOrDefault(extension, "application/octet-stream"); }