Skip to content

Commit

Permalink
Fix: static serve and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
NobleMajo committed Oct 17, 2024
1 parent a65f5d1 commit 481a59a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bunrouter",
"version": "1.0.0",
"version": "1.0.1",
"module": "src/index.ts",
"type": "module",
"scripts": {
Expand All @@ -12,4 +12,4 @@
"peerDependencies": {
"typescript": "^5.6.2"
}
}
}
19 changes: 8 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1157,24 +1157,21 @@ export class Router {

const staticMiddleware: RequestMiddleware =
(req, res) => {
if (req.path.endsWith("/" + indexFile)) {
res.sendRedirect(
req.path.slice(0, -indexFile.length),
true,
)
return
}

let targetPath = join(
targetDir,
req.splitPath == undefined ?
"/" :
req.path
)

if (targetPath.endsWith("/" + indexFile)) {
res.sendRedirect(
targetPath.substring(
0,
targetPath.length - indexFile.length - 1
),
true,
)
return
}

if (targetPath.endsWith("/")) {
targetPath += indexFile
}
Expand Down

0 comments on commit 481a59a

Please sign in to comment.