hypercore-fetch 9.0.4 → 9.0.5

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 +7 -2
  2. package/package.json +1 -1
  3. package/test.js +11 -5
package/index.js CHANGED
@@ -327,7 +327,11 @@ export default async function makeHyperFetch ({
327
327
  } else {
328
328
  await pipelinePromise(
329
329
  Readable.from(request.body),
330
- drive.createWriteStream(pathname)
330
+ drive.createWriteStream(pathname, {
331
+ metadata: {
332
+ mtime: Date.now()
333
+ }
334
+ })
331
335
  )
332
336
  }
333
337
 
@@ -617,7 +621,8 @@ async function resolvePath (drive, pathname, noResolve) {
617
621
  async function listEntries (drive, pathname = '/') {
618
622
  const entries = []
619
623
  for await (const path of drive.readdir(pathname)) {
620
- const stat = await drive.entry(path)
624
+ const fullPath = posix.join(pathname, path)
625
+ const stat = await drive.entry(fullPath)
621
626
  if (stat === null) {
622
627
  entries.push(path + '/')
623
628
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore-fetch",
3
- "version": "9.0.4",
3
+ "version": "9.0.5",
4
4
  "description": "Implementation of Fetch that uses the Dat SDK for loading p2p content",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/test.js CHANGED
@@ -104,7 +104,7 @@ test('GET full url for created keys', async (t) => {
104
104
  t.ok(createdURL.startsWith('hyper://'), 'Got new hyper:// URL')
105
105
 
106
106
  const nowExistingResponse = await fetch(keyURL)
107
- await checkResponse(nowExistingResponse, t,'GET no longer fails on create')
107
+ await checkResponse(nowExistingResponse, t, 'GET no longer fails on create')
108
108
 
109
109
  const existingURL = await nowExistingResponse.text()
110
110
 
@@ -182,10 +182,16 @@ test('PUT into new directory', async (t) => {
182
182
  t.equal(contentType, 'text/plain; charset=utf-8', 'Content got expected mime type')
183
183
  t.equal(content, SAMPLE_CONTENT, 'Got uploaded content back out')
184
184
 
185
- const listDirRequest = await fetch(created)
186
- await checkResponse(listDirRequest, t)
187
- const entries = await listDirRequest.json()
188
- t.deepEqual(entries, ['subfolder/'], 'new files are listed')
185
+ const topDirResponse = await fetch(created)
186
+ await checkResponse(topDirResponse, t)
187
+ const topDirEntries = await topDirResponse.json()
188
+ t.deepEqual(topDirEntries, ['subfolder/'], 'subdirectory is listed')
189
+
190
+ const subDir = new URL('./subfolder/', created)
191
+ const subDirResponse = await fetch(subDir)
192
+ await checkResponse(subDirResponse, t)
193
+ const subDirEntries = await subDirResponse.json()
194
+ t.deepEqual(subDirEntries, ['example.txt'], 'new file is listed')
189
195
  })
190
196
  test('PUT to overwrite a file', async (t) => {
191
197
  const created = await nextURL(t)