Skip to content

Commit 118c0f1

Browse files
updated nestedparams
1 parent 753e9db commit 118c0f1

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

src/main/wrapper/CxWrapper.ts

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,13 +414,43 @@ export class CxWrapper {
414414
return params;
415415
}
416416

417+
// Initial split (handles quoted strings)
417418
const paramList = additionalParameters.match(/(?:[^\s"]+|"[^"]*")+/g);
418-
logger.info("Additional parameters refined: " + paramList)
419+
logger.info("Additional parameters refined: " + paramList);
420+
419421
if (paramList) {
420-
paramList.forEach((element) => {
421-
params.push(element);
422+
const skipIndices = new Set<number>();
423+
424+
paramList.forEach((element, i) => {
425+
// Skip if this index was already processed as a value
426+
if (skipIndices.has(i)) {
427+
return;
428+
}
429+
430+
// Handle --sca-resolver-params or similar flags
431+
if (element === "--sca-resolver-params" && i + 1 < paramList.length) {
432+
const rawValue = paramList[i + 1];
433+
434+
// Remove outer quotes if present
435+
const unquoted = rawValue.startsWith('"') && rawValue.endsWith('"')
436+
? rawValue.slice(1, -1)
437+
: rawValue;
438+
439+
// Split inner string using shell-like logic (e.g., keeping inner quotes)
440+
const nestedParams = unquoted.match(/(?:[^\s"']+|'[^']*'|"[^"]*")+/g);
441+
442+
if (nestedParams) {
443+
nestedParams.forEach(p => params.push(p));
444+
}
445+
446+
// Mark the next index as processed
447+
skipIndices.add(i + 1);
448+
} else {
449+
params.push(element);
450+
}
422451
});
423452
}
453+
424454
return params;
425455
}
426456

0 commit comments

Comments
 (0)