@@ -83,27 +83,30 @@ test("content disposition without specifying filename", async () => {
8383
8484test ( "content disposition with specifying filename" , async ( ) => {
8585 const content = genRandomBlob ( 1024 )
86- const filename = "hello.jpg"
87- const altFilename = "world.txt"
86+ const filename = "りんご たいへん.jpg"
87+ const filenameEncoded = encodeURIComponent ( filename )
88+ const altFilename = "التفاح"
89+ const altFilenameEncoded = encodeURIComponent ( altFilename )
90+
8891 const ctx = createExecutionContext ( )
8992
9093 const uploadResp = await upload ( ctx , { c : { content, filename } } )
91- const url = uploadResp [ " url" ]
94+ const url = uploadResp . url
9295
93- expect ( uploadResp [ " suggestedUrl" ] ) . toStrictEqual ( `${ url } /${ filename } ` )
96+ expect ( uploadResp . suggestedUrl ) . toStrictEqual ( `${ url } /${ filenameEncoded } ` )
9497
9598 expect ( ( await workerFetch ( ctx , url ) ) . headers . get ( "Content-Disposition" ) ) . toStrictEqual (
96- `inline; filename*=UTF-8''${ filename } ` ,
99+ `inline; filename*=UTF-8''${ filenameEncoded } ` ,
97100 )
98101 expect ( ( await workerFetch ( ctx , `${ url } ?a` ) ) . headers . get ( "Content-Disposition" ) ) . toStrictEqual (
99- `attachment; filename*=UTF-8''${ filename } ` ,
102+ `attachment; filename*=UTF-8''${ filenameEncoded } ` ,
100103 )
101104
102105 expect ( ( await workerFetch ( ctx , `${ url } /${ altFilename } ` ) ) . headers . get ( "Content-Disposition" ) ) . toStrictEqual (
103- `inline; filename*=UTF-8''${ altFilename } ` ,
106+ `inline; filename*=UTF-8''${ altFilenameEncoded } ` ,
104107 )
105108 expect ( ( await workerFetch ( ctx , `${ url } /${ altFilename } ?a` ) ) . headers . get ( "Content-Disposition" ) ) . toStrictEqual (
106- `attachment; filename*=UTF-8''${ altFilename } ` ,
109+ `attachment; filename*=UTF-8''${ altFilenameEncoded } ` ,
107110 )
108111} )
109112
0 commit comments