@@ -133,7 +133,23 @@ const server = setupServer(
133
133
ctx . body ( content )
134
134
)
135
135
} ) ,
136
+ // Should test with non-ascii word `개` (which means dog in Korean)
137
+ rest . get (
138
+ `http://external.com/${ encodeURIComponent ( `개` ) } .jpg` ,
139
+ async ( req , res , ctx ) => {
140
+ const { content, contentLength } = await getFileContent (
141
+ path . join ( __dirname , `./fixtures/dog-thumbnail.jpg` ) ,
142
+ req
143
+ )
136
144
145
+ return res (
146
+ ctx . set ( `Content-Type` , `image/jpg` ) ,
147
+ ctx . set ( `Content-Length` , contentLength ) ,
148
+ ctx . status ( 200 ) ,
149
+ ctx . body ( content )
150
+ )
151
+ }
152
+ ) ,
137
153
rest . get ( `http://external.com/dog` , async ( req , res , ctx ) => {
138
154
const { content, contentLength } = await getFileContent (
139
155
path . join ( __dirname , `./fixtures/dog-thumbnail.jpg` ) ,
@@ -333,6 +349,33 @@ describe(`fetch-remote-file`, () => {
333
349
expect ( gotStream ) . toBeCalledTimes ( 1 )
334
350
} )
335
351
352
+ it ( `downloads and create a jpg file for file with non-ascii url` , async ( ) => {
353
+ const filePath = await fetchRemoteFile ( {
354
+ url : `http://external.com/${ encodeURIComponent ( `개` ) } .jpg` ,
355
+ cache,
356
+ } )
357
+
358
+ expect ( path . basename ( filePath ) ) . toBe ( `개.jpg` )
359
+ expect ( getFileSize ( filePath ) ) . resolves . toBe (
360
+ await getFileSize ( path . join ( __dirname , `./fixtures/dog-thumbnail.jpg` ) )
361
+ )
362
+ expect ( gotStream ) . toBeCalledTimes ( 1 )
363
+ } )
364
+
365
+ it ( `downloads and create a jpg file for file with non-ascii filename` , async ( ) => {
366
+ const filePath = await fetchRemoteFile ( {
367
+ url : `http://external.com/dog.jpg` ,
368
+ name : `${ encodeURIComponent ( `개` ) } ` ,
369
+ cache,
370
+ } )
371
+
372
+ expect ( path . basename ( filePath ) ) . toBe ( `개.jpg` )
373
+ expect ( getFileSize ( filePath ) ) . resolves . toBe (
374
+ await getFileSize ( path . join ( __dirname , `./fixtures/dog-thumbnail.jpg` ) )
375
+ )
376
+ expect ( gotStream ) . toBeCalledTimes ( 1 )
377
+ } )
378
+
336
379
it ( `downloads and create a jpg file for unknown extension` , async ( ) => {
337
380
const filePath = await fetchRemoteFile ( {
338
381
url : `http://external.com/dog` ,
0 commit comments