improved content types
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@bearmetal/router",
|
||||
"description": "A simple router for Deno",
|
||||
"version": "0.2.4",
|
||||
"version": "0.2.5",
|
||||
"stable": true,
|
||||
"files": [
|
||||
"mod.ts",
|
||||
|
@@ -393,7 +393,7 @@ export class Router {
|
||||
|
||||
try {
|
||||
const file = await Deno.readFile(normalizedPath);
|
||||
const filetype = normalizedPath.split(".")[1];
|
||||
const filetype = normalizedPath.split(".").at(-1);
|
||||
const contentType = getContentTypeByExtension(filetype);
|
||||
return new Response(file, { headers: { "Content-Type": contentType } });
|
||||
} catch (e) {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
export function getContentTypeByExtension(extension: string) {
|
||||
export function getContentTypeByExtension(extension?: string) {
|
||||
switch (extension) {
|
||||
case "html":
|
||||
case "htm":
|
||||
|
Reference in New Issue
Block a user