This repository was archived by the owner on Apr 29, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +38
-2
lines changed Expand file tree Collapse file tree 3 files changed +38
-2
lines changed Original file line number Diff line number Diff line change 40
40
"chai" : " ^4.2.0" ,
41
41
"detect-node" : " ^2.0.4" ,
42
42
"dirty-chai" : " ^2.0.1" ,
43
- "ipfs-unixfs-importer" : " ~0.34 .0" ,
43
+ "ipfs-unixfs-importer" : " ~0.36 .0" ,
44
44
"ipld" : " ~0.20.0" ,
45
45
"ipld-dag-pb" : " ~0.15.0" ,
46
46
"pull-pushable" : " ^2.2.0" ,
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ function pathBaseAndRest (path) {
31
31
32
32
return {
33
33
base : pathBase ,
34
- rest : pathRest . split ( '/' ) . filter ( Boolean )
34
+ rest : toPathComponents ( pathRest )
35
35
}
36
36
}
37
37
@@ -104,3 +104,11 @@ function join (paths) {
104
104
return acc + path
105
105
} , '' )
106
106
}
107
+
108
+ const toPathComponents = ( path = '' ) => {
109
+ // split on / unless escaped with \
110
+ return ( path
111
+ . trim ( )
112
+ . match ( / ( [ ^ \\ \] [ ^ / ] | \\ \/ ) + / g) || [ ] )
113
+ . filter ( Boolean )
114
+ }
Original file line number Diff line number Diff line change @@ -229,6 +229,34 @@ describe('exporter', () => {
229
229
} )
230
230
} )
231
231
232
+ it ( 'small file in a directory with an escaped slash in the title' , ( done ) => {
233
+ const fileName = `small-\\/file-${ Math . random ( ) } .txt`
234
+ const filePath = `/foo/${ fileName } `
235
+
236
+ pull (
237
+ pull . values ( [ {
238
+ path : filePath ,
239
+ content : pull . values ( [ smallFile ] )
240
+ } ] ) ,
241
+ importer ( ipld ) ,
242
+ pull . collect ( ( err , files ) => {
243
+ expect ( err ) . to . not . exist ( )
244
+
245
+ const path = `/ipfs/${ new CID ( files [ 1 ] . multihash ) . toBaseEncodedString ( ) } /${ fileName } `
246
+
247
+ pull (
248
+ exporter ( path , ipld ) ,
249
+ pull . collect ( ( err , files ) => {
250
+ expect ( err ) . to . not . exist ( )
251
+ expect ( files . length ) . to . equal ( 1 )
252
+ expect ( files [ 0 ] . path ) . to . equal ( fileName )
253
+ done ( )
254
+ } )
255
+ )
256
+ } )
257
+ )
258
+ } )
259
+
232
260
it ( 'exports a chunk of a file with no links' , ( done ) => {
233
261
const offset = 0
234
262
const length = 5
You can’t perform that action at this time.
0 commit comments