mirror of
https://github.com/gchq/CyberChef
synced 2025-01-08 10:38:46 +00:00
fix args transformation for ops with editableOptions
This commit is contained in:
parent
e04f66f599
commit
2ff7b5902c
2 changed files with 6 additions and 4 deletions
|
@ -13,11 +13,15 @@ import SyncDish from "./SyncDish";
|
||||||
* @param {Object} arg - an arg from an operation
|
* @param {Object} arg - an arg from an operation
|
||||||
*/
|
*/
|
||||||
function extractArg(arg) {
|
function extractArg(arg) {
|
||||||
if (arg.type === "option" || arg.type === "editableOption") {
|
if (arg.type === "option") {
|
||||||
// pick default option if not already chosen
|
// pick default option if not already chosen
|
||||||
return typeof arg.value === "string" ? arg.value : arg.value[0];
|
return typeof arg.value === "string" ? arg.value : arg.value[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (arg.type === "editableOption") {
|
||||||
|
return typeof arg.value === "string" ? arg.value : arg.value[0].value;
|
||||||
|
}
|
||||||
|
|
||||||
if (arg.type === "toggleString") {
|
if (arg.type === "toggleString") {
|
||||||
// ensure string and option exist when user hasn't defined
|
// ensure string and option exist when user hasn't defined
|
||||||
arg.string = arg.string || "";
|
arg.string = arg.string || "";
|
||||||
|
@ -96,7 +100,6 @@ export function wrap(OpClass) {
|
||||||
const type = SyncDish.typeEnum(input.constructor.name);
|
const type = SyncDish.typeEnum(input.constructor.name);
|
||||||
dish.set(input, type);
|
dish.set(input, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
args = transformArgs(operation.args, args);
|
args = transformArgs(operation.args, args);
|
||||||
const transformedInput = dish.get(operation.inputType);
|
const transformedInput = dish.get(operation.inputType);
|
||||||
const result = operation.run(transformedInput, args);
|
const result = operation.run(transformedInput, args);
|
||||||
|
|
|
@ -132,8 +132,7 @@ color: white;
|
||||||
alphabet: "0-9A-W",
|
alphabet: "0-9A-W",
|
||||||
});
|
});
|
||||||
assert.strictEqual(result.toString(), "SPI1R1T0");
|
assert.strictEqual(result.toString(), "SPI1R1T0");
|
||||||
})
|
}),
|
||||||
|
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue