Skip to content

Commit b69fd55

Browse files
author
Michael Jackson
committed
Fix 404 regression with CommonJS module paths
1 parent a254a7a commit b69fd55

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

server/middleware/findFile.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ function searchEntries(tarballStream, entryName, wantsHTML) {
8585
// and the client wants HTML.
8686
if (
8787
entry.name === entryName ||
88-
(wantsHTML && entry.name === entryName + "/index.html")
88+
(wantsHTML && entry.name === entryName + "/index.html") ||
89+
// Allow accessing e.g. `/index.js` or `/index.json` using
90+
// `/index` for compatibility with CommonJS
91+
(!wantsHTML && entry.name === entryName + ".js") ||
92+
(!wantsHTML && entry.name === entryName + ".json")
8993
) {
9094
foundEntry = entry;
9195
}

0 commit comments

Comments
 (0)