herudi / static-files

Serve Static for Deno.
MIT License
9 stars 3 forks source link

doesn't serve file when expected #1

Closed peetklecha closed 2 years ago

peetklecha commented 2 years ago

i was experiencing a problem where the library was not working as expected to serve a file that was clearly present/being requested. i was able to fix the issue locally by modifying line 98 of /src/utils.ts:

      (contentType(pathFile.replace("/", "\\")) || "application/octet-stream"),

i changed it to:

      (contentType(pathFile.replaceAll("/", "")) || "application/octet-stream"),

and it began to work. however, i'm not sure this is really the best fix. the real problem, it seems to me, is that it is calling contentType on pathFile (the full absolute file path) rather than just the filename (index.js or whatever).

herudi commented 2 years ago

ah, ok. in line 98, read extension for finded content type. maybe fail with \\ for other unix. can you please make a PR ?