hypercore-fetch 9.2.0 → 9.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +21 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -27,6 +27,14 @@ const HEADER_LAST_MODIFIED = 'Last-Modified'
|
|
|
27
27
|
|
|
28
28
|
export const ERROR_KEY_NOT_CREATED = 'Must create key with POST before reading'
|
|
29
29
|
|
|
30
|
+
const INDEX_FILES = [
|
|
31
|
+
'index.html',
|
|
32
|
+
'index.md',
|
|
33
|
+
'index.gmi',
|
|
34
|
+
'index.gemini',
|
|
35
|
+
'README.md'
|
|
36
|
+
]
|
|
37
|
+
|
|
30
38
|
async function DEFAULT_RENDER_INDEX (url, files, fetch) {
|
|
31
39
|
return `
|
|
32
40
|
<!DOCTYPE html>
|
|
@@ -459,12 +467,15 @@ export default async function makeHyperFetch ({
|
|
|
459
467
|
}
|
|
460
468
|
|
|
461
469
|
if (!noResolve) {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
470
|
+
for (const indexFile of INDEX_FILES) {
|
|
471
|
+
if (entries.includes(indexFile)) {
|
|
472
|
+
const mimeType = getMimeType(indexFile)
|
|
473
|
+
return {
|
|
474
|
+
status: 204,
|
|
475
|
+
headers: {
|
|
476
|
+
...resHeaders,
|
|
477
|
+
[HEADER_CONTENT_TYPE]: mimeType
|
|
478
|
+
}
|
|
468
479
|
}
|
|
469
480
|
}
|
|
470
481
|
}
|
|
@@ -591,8 +602,10 @@ export default async function makeHyperFetch ({
|
|
|
591
602
|
}
|
|
592
603
|
|
|
593
604
|
if (!noResolve) {
|
|
594
|
-
|
|
595
|
-
|
|
605
|
+
for (const indexFile of INDEX_FILES) {
|
|
606
|
+
if (entries.includes(indexFile)) {
|
|
607
|
+
return serveFile(drive, posix.join(pathname, 'indexFile'), isRanged)
|
|
608
|
+
}
|
|
596
609
|
}
|
|
597
610
|
}
|
|
598
611
|
|