Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit df0ee38

Browse files
alanshawdaviddias
authored andcommitted
fixes error thrown when path is empty refs #649
1 parent 5d5218f commit df0ee38

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/utils/prepare-file.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function prepareFile (file, opts) {
9090
return file
9191
}
9292

93-
if (file.path && (file.content || file.dir)) {
93+
if (file.content || file.dir) {
9494
return file
9595
}
9696

test/files.spec.js

+14
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,20 @@ describe('.files (the MFS API part)', function () {
6262
})
6363
})
6464

65+
it.only('files.add with empty path and buffer content', (done) => {
66+
const expectedHash = 'QmWfVY9y3xjsixTgbd9AorQxH7VtMpzfx2HaWtsoUYecaX'
67+
const content = Buffer.from('hello')
68+
69+
ipfs.files.add([{ path: '', content }], (err, res) => {
70+
expect(err).to.not.exist()
71+
72+
expect(res).to.have.length(1)
73+
expect(res[0].hash).to.equal(expectedHash)
74+
expect(res[0].path).to.equal(expectedHash)
75+
done()
76+
})
77+
})
78+
6579
it('files.add with cid-version=1 and raw-leaves=false', (done) => {
6680
const expectedCid = 'zdj7Wh9x6gXdg4UAqhRYnjBTw9eJF7hvzUU4HjpnZXHYQz9jK'
6781
const options = { 'cid-version': 1, 'raw-leaves': false }

0 commit comments

Comments
 (0)