File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -638,6 +638,22 @@ describe('S3Adapter tests', () => {
638638 expect ( fileLocation ) . toContain ( 'X-Amz-Algorithm=AWS4-HMAC-SHA256' ) ;
639639 expect ( fileLocation ) . toContain ( 'X-Amz-SignedHeaders=host' ) ;
640640 } ) ;
641+
642+ it ( 'should not double-encode special characters in presigned URLs' , async ( ) => {
643+ delete options . baseUrl ;
644+ options . presignedUrl = true ;
645+ const s3 = new S3Adapter ( 'accessKey' , 'secretKey' , 'my-bucket' , options ) ;
646+
647+ // Test filename with special characters that need URL encoding
648+ const specialFilename = 'doc[123].pdf' ;
649+ const fileLocation = await s3 . getFileLocation ( testConfig , specialFilename ) ;
650+
651+ // Should be encoded once (not double-encoded)
652+ // %5B and %5D are correct encoding for [ and ]
653+ // Double encoding would be %255B and %255D
654+ expect ( fileLocation ) . toContain ( 'doc%5B123%5D.pdf' ) ;
655+ expect ( fileLocation ) . not . toContain ( 'doc%255B123%255D.pdf' ) ;
656+ } ) ;
641657 } ) ;
642658
643659 describe ( 'getFileLocation with async baseUrl' , ( ) => {
You can’t perform that action at this time.
0 commit comments