Add ?module support for HTML files

Closes #113
This commit is contained in:
Michael Jackson
2018-09-04 15:58:52 -07:00
parent 311a1ffa7e
commit 21ed6ee42e
7 changed files with 187 additions and 31 deletions

View File

@ -84,8 +84,10 @@ function searchEntries(tarballStream, entryName, wantsHTML) {
// and the client wants HTML.
if (
entry.name === entryName ||
// Allow accessing e.g. `/lib/index.html` using `/lib/`
(wantsHTML && entry.name === `${entryName}/index.html`) ||
// Allow accessing e.g. `/index.html` using `/`
(wantsHTML &&
entry.name ===
(entryName === "" ? "index.html" : `${entryName}/index.html`)) ||
// Allow accessing e.g. `/index.js` or `/index.json` using
// `/index` for compatibility with CommonJS
(!wantsHTML && entry.name === `${entryName}.js`) ||