@@ -58,13 +58,21 @@ export default function routePOST(
5858 corsHeaders ) ) ;
5959 }
6060
61- if ( objectKey === undefined ) {
62- if ( Object . keys ( query ) . length > 0 ) {
63- return routesUtils . responseNoBody ( errors . InvalidArgument
64- . customizeDescription ( "Query String Parameters not allowed on POST requests." ) , null ,
65- response , 400 , log ) ;
61+ // Handle objectKey and query string conditions
62+ if ( objectKey !== undefined ) {
63+ if ( Object . keys ( query ) . length === 0 ) {
64+ return api . callPostObject ( 'objectPost' , request , response , log , ( err , resHeaders ) =>
65+ routesUtils . responseNoBody ( err , resHeaders , response , 204 , log ) ) ;
66+ } else {
67+ // If there's an objectKey and a query string but no match with the previous conditions
68+ return routesUtils . responseNoBody ( errors . MethodNotAllowed , null , response , 405 , log ) ;
6669 }
67- return api . callPostObject ( 'objectPost' , request , response , log , ( err , resHeaders ) => routesUtils . responseNoBody ( err , resHeaders , response , 204 , log ) ) ;
70+ }
71+
72+ // Handle invalid query string parameters
73+ if ( Object . keys ( query ) . length > 0 ) {
74+ return routesUtils . responseNoBody ( errors . InvalidArgument
75+ . customizeDescription ( "Query String Parameters not allowed on POST requests." ) , null , response , 400 , log ) ;
6876 }
6977
7078 return routesUtils . responseNoBody ( errors . NotImplemented , null , response ,
0 commit comments