Skip to content

Commit

Permalink
Fix double-decode on presigm param
Browse files Browse the repository at this point in the history
This was only passing the tests because we incorrecly were double-encoding the presigned params too.
  • Loading branch information
joehoyle committed May 7, 2024
1 parent de6067b commit 5376b08
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lambda-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const streamify_handler: StreamifyHandler = async ( event, response ) => {
// If there is a presign param, we need to decode it and add it to the args. This is to provide a secondary way to pass pre-sign params,
// as using them in a Lambda function URL invocation will trigger a Lambda error.
if ( args.presign ) {
const presignArgs = new URLSearchParams( decodeURIComponent( args.presign ) );
const presignArgs = new URLSearchParams( args.presign );
for ( const [ key, value ] of presignArgs.entries() ) {
args[ key as keyof Args ] = value;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-private-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ test( 'Test get private upload with presign params', async () => {
'headers': {
},
'queryStringParameters': {
presign: encodeURIComponent( new URLSearchParams( presignParams ).toString() ),
presign: new URLSearchParams( presignParams ).toString(),
},
'isBase64Encoded': false,
};
Expand Down

0 comments on commit 5376b08

Please sign in to comment.