This repository was archived by the owner on Mar 10, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ const flatmap = require('flatmap')
66const escape = require ( 'glob-escape' )
77
88function headers ( file ) {
9- const name = file . path || ''
9+ const name = encodeURIComponent ( file . path ) || ''
1010 const header = {
1111 'Content-Disposition' : `file; filename="${ name } "`
1212 }
Original file line number Diff line number Diff line change @@ -156,6 +156,37 @@ describe('.get', () => {
156156 } )
157157 } )
158158 } )
159+
160+ it ( 'add path containing "+"s (for testing get)' , ( done ) => {
161+ if ( ! isNode ) { return done ( ) }
162+ const filename = 'ti,c64x+mega++mod-pic.txt'
163+ const subdir = 'tmp/c++files'
164+ const expectedMultihash = 'QmPkmARcqjo5fqK1V1o8cFsuaXxWYsnwCNLJUYS4KeZyff'
165+ ipfs . files . add ( [ {
166+ path : subdir + '/' + filename ,
167+ content : Buffer . from ( subdir + '/' + filename , 'utf-8' )
168+ } ] , ( err , res ) => {
169+ if ( err ) done ( err )
170+ expect ( res [ 2 ] . hash ) . to . equal ( expectedMultihash )
171+ done ( )
172+ } )
173+ } )
174+
175+ it ( 'get path containing "+"s' , ( done ) => {
176+ if ( ! isNode ) { return done ( ) }
177+ const multihash = 'QmPkmARcqjo5fqK1V1o8cFsuaXxWYsnwCNLJUYS4KeZyff'
178+ let count = 0
179+ ipfs . get ( multihash , ( err , files ) => {
180+ expect ( err ) . to . not . exist ( )
181+ files . on ( 'data' , ( file ) => {
182+ if ( file . path !== multihash ) {
183+ count ++
184+ expect ( file . path ) . to . contain ( '+' )
185+ if ( count === 2 ) done ( )
186+ }
187+ } )
188+ } )
189+ } )
159190 } )
160191
161192 describe ( 'Promise API' , ( ) => {
You can’t perform that action at this time.
0 commit comments