This repository was archived by the owner on Apr 29, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Expand file tree Collapse file tree 2 files changed +37
-1
lines changed 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
@@ -103,3 +103,11 @@ function join (paths) {
103
103
return acc + path
104
104
} , '' )
105
105
}
106
+
107
+ const toPathComponents = ( path = '' ) => {
108
+ // split on / unless escaped with \
109
+ return ( path
110
+ . trim ( )
111
+ . match ( / ( [ ^ \\ \] [ ^ / ] | \\ \/ ) + / g) || [ ] )
112
+ . filter ( Boolean )
113
+ }
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