@@ -546,15 +546,20 @@ export function getAsPowerShellString(yasqe: Yasqe, _config?: Config["requestCon
546546 }
547547
548548 // Build the body with the query variable and any other parameters
549- const bodyParts : string [ ] = [ ] ;
550- if ( queryParam ) {
551- bodyParts . push ( `${ queryParamName } =$${ queryParamName } ` ) ;
552- }
553- if ( Object . keys ( otherArgs ) . length > 0 ) {
549+ // Note: We don't escape the variable reference itself, only the other args
550+ let bodyExpression : string ;
551+ if ( queryParam && Object . keys ( otherArgs ) . length > 0 ) {
552+ // Both query variable and other args
553+ const otherArgsString = queryString . stringify ( otherArgs ) ;
554+ bodyExpression = `"${ queryParamName } =$${ queryParamName } &${ escapePowerShellString ( otherArgsString ) } "` ;
555+ } else if ( queryParam ) {
556+ // Only query variable
557+ bodyExpression = `"${ queryParamName } =$${ queryParamName } "` ;
558+ } else {
559+ // Only other args (shouldn't happen, but handle it)
554560 const otherArgsString = queryString . stringify ( otherArgs ) ;
555- bodyParts . push ( otherArgsString ) ;
561+ bodyExpression = `" ${ escapePowerShellString ( otherArgsString ) } "` ;
556562 }
557- const body = bodyParts . join ( "&" ) ;
558563
559564 lines . push ( "$params = @{" ) ;
560565 lines . push ( ` Uri = "${ escapePowerShellString ( url ) } "` ) ;
@@ -565,7 +570,7 @@ export function getAsPowerShellString(yasqe: Yasqe, _config?: Config["requestCon
565570 lines . push ( " }" ) ;
566571 }
567572 lines . push ( ` ContentType = "application/x-www-form-urlencoded"` ) ;
568- lines . push ( ` Body = " ${ escapePowerShellString ( body ) } " ` ) ;
573+ lines . push ( ` Body = ${ bodyExpression } ` ) ;
569574 lines . push ( ` OutFile = "sparql-generated.${ fileExtension } "` ) ;
570575 lines . push ( "}" ) ;
571576 } else {
0 commit comments