@@ -42,7 +42,7 @@ export async function getAbility( name: string ): Promise< Ability | null > {
4242 */
4343export async function executeAbility (
4444 name : string ,
45- input : AbilityInput = { }
45+ input : AbilityInput = null
4646) : Promise < AbilityOutput > {
4747 const ability = await getAbility ( name ) ;
4848 if ( ! ability ) {
@@ -60,14 +60,20 @@ export async function executeAbility(
6060 method,
6161 } ;
6262
63- if ( method === 'GET' && Object . keys ( input ) . length > 0 ) {
63+ if ( method === 'GET' && input !== null && typeof input === 'object' && ! Array . isArray ( input ) && Object . keys ( input ) . length > 0 ) {
64+ // For GET requests with object inputs, convert to URL parameters
6465 // e.g., input[format]=iso&input[timezone]=UTC
6566 const params = new URLSearchParams ( ) ;
6667 Object . entries ( input ) . forEach ( ( [ key , value ] ) => {
6768 params . append ( `input[${ key } ]` , String ( value ) ) ;
6869 } ) ;
6970 path = `${ path } ?${ params . toString ( ) } ` ;
70- } else if ( method === 'POST' ) {
71+ } else if ( method === 'GET' && input !== null ) {
72+ // For GET requests with non-object inputs, pass as single parameter
73+ const params = new URLSearchParams ( ) ;
74+ params . append ( 'input' , JSON . stringify ( input ) ) ;
75+ path = `${ path } ?${ params . toString ( ) } ` ;
76+ } else if ( method === 'POST' && input !== null ) {
7177 options . data = { input } ;
7278 }
7379
0 commit comments