This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree 2 files changed +32
-1
lines changed
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')
6
6
const escape = require ( 'glob-escape' )
7
7
8
8
function headers ( file ) {
9
- const name = file . path || ''
9
+ const name = encodeURIComponent ( file . path ) || ''
10
10
const header = {
11
11
'Content-Disposition' : `file; filename="${ name } "`
12
12
}
Original file line number Diff line number Diff line change @@ -156,6 +156,37 @@ describe('.get', () => {
156
156
} )
157
157
} )
158
158
} )
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
+ } )
159
190
} )
160
191
161
192
describe ( 'Promise API' , ( ) => {
You can’t perform that action at this time.
0 commit comments