From 5292420767598b18e4937655e74cf0cb66c32bb0 Mon Sep 17 00:00:00 2001 From: Etienne Noel Date: Fri, 8 Mar 2024 20:56:07 -0800 Subject: [PATCH] - Update. --- packages/http/src/servers/file.http-server.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/http/src/servers/file.http-server.ts b/packages/http/src/servers/file.http-server.ts index 6ec7ff37..6c6de25e 100644 --- a/packages/http/src/servers/file.http-server.ts +++ b/packages/http/src/servers/file.http-server.ts @@ -45,7 +45,7 @@ export class FileHttpServer { // extract URL path let pathname = path.join(directory, `${parsedUrl.pathname}`); // based on the URL path, extract the file extension. e.g. .js, .doc, ... - const ext = path.parse(pathname).ext; + let ext = path.parse(pathname).ext; // maps file extension to MIME typere const map: {[key in string]: string} = { ".aac": "audio/aac", @@ -133,7 +133,8 @@ export class FileHttpServer { // if is a directory search for index file matching the extension if (fs.statSync(pathname).isDirectory()) { - pathname += 'index.html'; + ext = "html"; + pathname += `index.${ext}`; } // read file from file system