Skip to content

Commit

Permalink
fix: don't try to read the content when the requested path is mapped …
Browse files Browse the repository at this point in the history
…to a directory (#105)
  • Loading branch information
daihuabin authored Apr 19, 2024
1 parent 27a9417 commit 32115f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/quiet-crews-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vite-plugin-static-copy": patch
---

don't crash when the requested path is mapped to a directory
2 changes: 1 addition & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export function serveStaticCopyMiddleware(

try {
const data = viaLocal(root, publicDir, fileMap, pathname)
if (!data) {
if (!data || data.stats.isDirectory()) {
return404(res, next)
return
}
Expand Down

0 comments on commit 32115f0

Please sign in to comment.