Skip to content

Commit

Permalink
Optimize a little + v0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobbouchard committed Jul 12, 2022
1 parent 474e2b1 commit ab71176
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.1.4] - 2022-07-12

### Changes

- Won't look for an index file if the path is not a directory.

## [0.1.3] - 2022-07-12

### Changes
Expand Down
5 changes: 4 additions & 1 deletion lib/serve-static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ export default function serveStatic(root: string, options: TOptions) {
async function getResponse(req: Request): Promise<Response> {
const pathname = getPathname(new URL(req.url));
const file = await getFileInfo(`${root}/${pathname}`);
const indexFile = options.index !== false ? await getFileInfo(`${root}/${pathname}/${options.index}`) : null;
const indexFile =
file.exists && !file.isFile && options.index !== false
? await getFileInfo(`${root}/${pathname}/${options.index}`)
: null;

// Redirect to path with normalized slashes
let redirectPath = pathname;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serve-static-bun",
"version": "0.1.3",
"version": "0.1.4",
"author": "Jakob Bouchard <jakob@jakobbouchard.dev>",
"repository": {
"type": "git",
Expand Down

0 comments on commit ab71176

Please sign in to comment.