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

Commit 986f945

Browse files
committed
fix: fix regex to match files with square brackets
1 parent 0a34a9f commit 986f945

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/utils/to-path-components.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const toPathComponents = (path = '') => {
44
// split on / unless escaped with \
55
return (path
66
.trim()
7-
.match(/([^\\\][^/]|\\\/)+/g) || [])
7+
.match(/([^\\\^/]|\\\/)+/g) || [])
88
.filter(Boolean)
99
}
1010

test/importer.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,24 @@ module.exports = (repo) => {
330330
)
331331
})
332332

333+
it('small file with square brackets in the title', (done) => {
334+
const filePath = `small-[v]-file-${Math.random()}.txt`
335+
336+
pull(
337+
values([{
338+
path: filePath,
339+
content: values([smallFile])
340+
}]),
341+
importer(ipld, options),
342+
collect((err, files) => {
343+
expect(err).to.not.exist()
344+
expect(files.length).to.equal(1)
345+
expect(files[0].path).to.equal(filePath)
346+
done()
347+
})
348+
)
349+
})
350+
333351
it('small file (smaller than a chunk)', (done) => {
334352
pull(
335353
values([{

0 commit comments

Comments
 (0)