From b69fd550a2571cf70aea86ef6768938ea20b5412 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Thu, 19 Jul 2018 21:03:40 -0400 Subject: [PATCH] Fix 404 regression with CommonJS module paths --- server/middleware/findFile.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/middleware/findFile.js b/server/middleware/findFile.js index 9221eba..81a3ee7 100644 --- a/server/middleware/findFile.js +++ b/server/middleware/findFile.js @@ -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; }