Fix 404 regression with CommonJS module paths

This commit is contained in:
Michael Jackson 2018-07-19 21:03:40 -04:00
parent a254a7a2f2
commit b69fd550a2
1 changed files with 5 additions and 1 deletions
server/middleware

View File

@ -85,7 +85,11 @@ function searchEntries(tarballStream, entryName, wantsHTML) {
// and the client wants HTML.
if (
entry.name === entryName ||
(wantsHTML && entry.name === entryName + "/index.html")
(wantsHTML && entry.name === entryName + "/index.html") ||
// Allow accessing e.g. `/index.js` or `/index.json` using
// `/index` for compatibility with CommonJS
(!wantsHTML && entry.name === entryName + ".js") ||
(!wantsHTML && entry.name === entryName + ".json")
) {
foundEntry = entry;
}