improved content types
This commit is contained in:
@@ -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",
|
||||||
|
@@ -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) {
|
||||||
|
@@ -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":
|
||||||
|
Reference in New Issue
Block a user