Skip to content

Commit

Permalink
Support any method for PowerShell
Browse files Browse the repository at this point in the history
  • Loading branch information
verhovsky committed Jun 11, 2023
1 parent cee79a5 commit bb13a49
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/targets/powershell/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,19 @@ export const generatePowershellConvert = (command: PowershellCommand) => {
allHeaders,
}) => {
const { push, join } = new CodeBuilder();
const methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'];

if (!methods.includes(method.toUpperCase())) {
return 'Method not supported';
}
const methods = [
'DEFAULT',
'DELETE',
'GET',
'HEAD',
'MERGE',
'OPTIONS',
'PATCH',
'POST',
'PUT',
'TRACE'
];
const methodArg = methods.includes(method.toUpperCase()) ? '-Method' : '-CustomMethod';

const commandOptions = [];

Expand Down Expand Up @@ -62,7 +70,7 @@ export const generatePowershellConvert = (command: PowershellCommand) => {
commandOptions.push(`-Body '${postData.text}'`);
}

push(`$response = ${command} -Uri '${fullUrl}' -Method ${method} ${commandOptions.join(' ')}`);
push(`$response = ${command} -Uri '${fullUrl}' ${methodArg} ${method} ${commandOptions.join(' ')}`);
return join();
};
return convert;
Expand Down

0 comments on commit bb13a49

Please sign in to comment.