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

Commit 667f6e9

Browse files
committed
fix: fix regext to not match square brackets
1 parent afb8b27 commit 667f6e9

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,6 @@ const toPathComponents = (path = '') => {
113113
// split on / unless escaped with \
114114
return (path
115115
.trim()
116-
.match(/([^\\\][^/]|\\\/)+/g) || [])
116+
.match(/([^\\^/]|\\\/)+/g) || [])
117117
.filter(Boolean)
118118
}

test/exporter.spec.js

+28
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,34 @@ describe('exporter', () => {
257257
)
258258
})
259259

260+
it('small file in a directory with an square brackets in the title', (done) => {
261+
const fileName = `small-[bar]-file-${Math.random()}.txt`
262+
const filePath = `/foo/${fileName}`
263+
264+
pull(
265+
pull.values([{
266+
path: filePath,
267+
content: pull.values([smallFile])
268+
}]),
269+
importer(ipld),
270+
pull.collect((err, files) => {
271+
expect(err).to.not.exist()
272+
273+
const path = `/ipfs/${new CID(files[1].multihash).toBaseEncodedString()}/${fileName}`
274+
275+
pull(
276+
exporter(path, ipld),
277+
pull.collect((err, files) => {
278+
expect(err).to.not.exist()
279+
expect(files.length).to.equal(1)
280+
expect(files[0].path).to.equal(fileName)
281+
done()
282+
})
283+
)
284+
})
285+
)
286+
})
287+
260288
it('exports a chunk of a file with no links', (done) => {
261289
const offset = 0
262290
const length = 5

0 commit comments

Comments
 (0)