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.
Files changed (2) hide show
  1. package/index.js +21 -8
  2. 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
- if (entries.includes('index.html')) {
463
- return {
464
- status: 204,
465
- headers: {
466
- ...resHeaders,
467
- [HEADER_CONTENT_TYPE]: MIME_TEXT_HTML
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
- if (entries.includes('index.html')) {
595
- return serveFile(drive, posix.join(pathname, 'index.html'), isRanged)
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore-fetch",
3
- "version": "9.2.0",
3
+ "version": "9.3.0",
4
4
  "description": "Implementation of Fetch that uses the Dat SDK for loading p2p content",
5
5
  "type": "module",
6
6
  "main": "index.js",