improved content types

This commit is contained in:
2025-01-21 01:23:41 -07:00
parent fcba2014c2
commit 1d3be78917
3 changed files with 3 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
{ {
"name": "@bearmetal/router", "name": "@bearmetal/router",
"description": "A simple router for Deno", "description": "A simple router for Deno",
"version": "0.2.4", "version": "0.2.5",
"stable": true, "stable": true,
"files": [ "files": [
"mod.ts", "mod.ts",

View File

@@ -393,7 +393,7 @@ export class Router {
try { try {
const file = await Deno.readFile(normalizedPath); const file = await Deno.readFile(normalizedPath);
const filetype = normalizedPath.split(".")[1]; const filetype = normalizedPath.split(".").at(-1);
const contentType = getContentTypeByExtension(filetype); const contentType = getContentTypeByExtension(filetype);
return new Response(file, { headers: { "Content-Type": contentType } }); return new Response(file, { headers: { "Content-Type": contentType } });
} catch (e) { } catch (e) {

View File

@@ -1,4 +1,4 @@
export function getContentTypeByExtension(extension: string) { export function getContentTypeByExtension(extension?: string) {
switch (extension) { switch (extension) {
case "html": case "html":
case "htm": case "htm":