Add content type to registry using filenames
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { ABC, Base64 } from "./deps.ts";
|
||||
import { ABC, Base64, Path } from "./deps.ts";
|
||||
import config from "./config.ts";
|
||||
|
||||
const packageNameRegex = /^[@]?[a-zA-Z][\d\w\-\_]*$/g.compile();
|
||||
@ -156,3 +156,18 @@ export async function getFile(
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
const exts = new Map<string, string>();
|
||||
|
||||
exts.set(".js", "text/javascript");
|
||||
exts.set(".mjs", "text/javascript");
|
||||
exts.set(".json", "application/json");
|
||||
exts.set(".jsonld", "application/ld+json");
|
||||
exts.set(".css", "text/css");
|
||||
exts.set(".html", "text/html");
|
||||
exts.set(".htm", "text/html");
|
||||
|
||||
export function getContentType(filename: string) {
|
||||
const ext = Path.extname(filename);
|
||||
return exts.get(ext);
|
||||
}
|
||||
|
Reference in New Issue
Block a user