Skip to content

Commit

Permalink
Add .cjs and .mjs to MIME types. Fix #25
Browse files Browse the repository at this point in the history
  • Loading branch information
PhantomYdn committed Mar 12, 2024
1 parent 4145417 commit 665651d
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions jnpm/src/main/java/org/orienteer/jnpm/JNPMUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ public static <K> Map<K, K> 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");
Expand Down Expand Up @@ -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");
}

Expand Down

0 comments on commit 665651d

Please sign in to comment.