hypercore-fetch 9.0.0 → 9.0.1

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 (3) hide show
  1. package/index.js +4 -4
  2. package/package.json +2 -2
  3. package/test.js +8 -0
package/index.js CHANGED
@@ -293,7 +293,7 @@ export default async function makeHyperFetch ({
293
293
  const contentType = request.headers.get('Content-Type') || ''
294
294
  const isFormData = contentType.includes('multipart/form-data')
295
295
 
296
- const drive = await getDrive(hostname)
296
+ const drive = await getDrive(`hyper://${hostname}`)
297
297
 
298
298
  if (isFormData) {
299
299
  // It's a form! Get the files out and process them
@@ -322,7 +322,7 @@ export default async function makeHyperFetch ({
322
322
  router.delete('hyper://*/**', async function putFiles (request) {
323
323
  const { hostname, pathname } = new URL(request.url)
324
324
 
325
- const drive = await getDrive(hostname)
325
+ const drive = await getDrive(`hyper://${hostname}`)
326
326
 
327
327
  if (pathname.endsWith('/')) {
328
328
  let didDelete = false
@@ -355,7 +355,7 @@ export default async function makeHyperFetch ({
355
355
  const noResolve = searchParams.has('noResolve')
356
356
  const isDirectory = pathname.endsWith('/')
357
357
 
358
- const drive = await getDrive(hostname)
358
+ const drive = await getDrive(`hyper://${hostname}`)
359
359
 
360
360
  const resHeaders = {
361
361
  ETag: `${drive.version}`,
@@ -458,7 +458,7 @@ export default async function makeHyperFetch ({
458
458
  const noResolve = searchParams.has('noResolve')
459
459
  const isDirectory = pathname.endsWith('/')
460
460
 
461
- const drive = await getDrive(hostname)
461
+ const drive = await getDrive(`hyper://${hostname}`)
462
462
 
463
463
  if (isDirectory) {
464
464
  const resHeaders = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore-fetch",
3
- "version": "9.0.0",
3
+ "version": "9.0.1",
4
4
  "description": "Implementation of Fetch that uses the Dat SDK for loading p2p content",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -25,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "event-iterator": "^2.0.0",
27
27
  "hyperdrive": "^11.0.0-alpha.10",
28
- "make-fetch": "^3.1.0",
28
+ "make-fetch": "^3.1.1",
29
29
  "mime": "^3.0.0",
30
30
  "range-parser": "^1.2.1",
31
31
  "streamx": "^2.13.0"
package/test.js CHANGED
@@ -322,6 +322,14 @@ test('Resolve pretty markdown URLs', async (t) => {
322
322
  t.equal(contentType, 'text/markdown; charset=utf-8', 'Got markdown mime type')
323
323
  })
324
324
 
325
+ test('Doing a `GET` on an invalid domain should cause an error', async (t) => {
326
+ const url = 'hyper://example/'
327
+
328
+ const failedResponse = await fetch(url)
329
+
330
+ t.notOk(failedResponse.ok, 'Response errored out due to invalid domain')
331
+ })
332
+
325
333
  test('EventSource extension messages', async (t) => {
326
334
  const domain = await nextURL(t)
327
335