Skip to content

Commit b4d7e68

Browse files
CopilotMathiasVDA
andcommitted
Address code review feedback - eliminate duplication in parameter name logic
Co-authored-by: MathiasVDA <15101339+MathiasVDA@users.noreply.github.com>
1 parent da82958 commit b4d7e68

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

packages/yasqe/src/sparql.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -524,20 +524,20 @@ export function getAsPowerShellString(yasqe: Yasqe, _config?: Config["requestCon
524524
lines.push("}");
525525
} else if (ajaxConfig.reqMethod === "POST") {
526526
// Extract the query/update parameter and other parameters separately
527-
const queryParam = ajaxConfig.args.query || ajaxConfig.args.update;
527+
// Determine the query parameter name first (query takes precedence over update)
528+
const queryParamName = ajaxConfig.args.query !== undefined ? "query" : "update";
529+
const queryParam = ajaxConfig.args[queryParamName];
530+
528531
const otherArgs: RequestArgs = {};
529532
for (const key in ajaxConfig.args) {
530533
if (key !== "query" && key !== "update") {
531534
otherArgs[key] = ajaxConfig.args[key];
532535
}
533536
}
534537

535-
// Determine the query parameter name
536-
const queryParamName = ajaxConfig.args.query !== undefined ? "query" : "update";
537-
538538
// Build the query string using here-string for easy editing
539539
if (queryParam) {
540-
// Handle both string and string[] cases
540+
// Handle both string and string[] cases - use first element if array
541541
const queryText = Array.isArray(queryParam) ? queryParam[0] : queryParam;
542542
lines.push(`$${queryParamName} = @"`);
543543
lines.push(queryText);

0 commit comments

Comments
 (0)