mirror of
https://github.com/gchq/CyberChef
synced 2025-01-19 16:04:00 +00:00
toggleString args now additionally accept just input value, taking first option as default.
This commit is contained in:
parent
f6c4b5073c
commit
7c9ebafd00
2 changed files with 32 additions and 3 deletions
|
@ -75,9 +75,13 @@ function transformArgs(originalArgs, newArgs) {
|
|||
|
||||
if (index > -1) {
|
||||
const argument = allArgs[index];
|
||||
if (["toggleString"].indexOf(argument.type) > -1) {
|
||||
argument.string = newArgs[key].string;
|
||||
argument.option = newArgs[key].option;
|
||||
if (argument.type === "toggleString") {
|
||||
if (typeof newArgs[key] === "string") {
|
||||
argument.string = newArgs[key];
|
||||
} else {
|
||||
argument.string = newArgs[key].string;
|
||||
argument.option = newArgs[key].option;
|
||||
}
|
||||
} else if (argument.type === "editableOption") {
|
||||
// takes key: "option", key: {name, val: "string"}, key: {name, val: [...]}
|
||||
argument.value = typeof newArgs[key] === "string" ? newArgs[key]: newArgs[key].value;
|
||||
|
|
|
@ -48,6 +48,14 @@ TestRegister.addApiTests([
|
|||
assert.equal(result.toString(), "aO[^ZS\u000eW\\^cb");
|
||||
}),
|
||||
|
||||
|
||||
it("ADD: default option toggleString argument", () => {
|
||||
const result = chef.ADD(3, {
|
||||
key: "4",
|
||||
});
|
||||
assert.strictEqual(result.toString(), "7");
|
||||
}),
|
||||
|
||||
it("addLineNumbers: No arguments", () => {
|
||||
const result = addLineNumbers("sample input");
|
||||
assert.equal(result.toString(), "1 sample input");
|
||||
|
@ -921,6 +929,23 @@ smothering ampersand abreast
|
|||
</contact-info>`);
|
||||
}),
|
||||
|
||||
it("XOR: toggleString with default option", () => {
|
||||
assert.strictEqual(chef.XOR("fe023da5", {
|
||||
key: "73 6f 6d 65"
|
||||
}).toString(),
|
||||
"\u0015\n]W@\u000b\fP");
|
||||
}),
|
||||
|
||||
it("XOR: toggleString with custom option", () => {
|
||||
assert.strictEqual(chef.XOR("fe023da5", {
|
||||
key: {
|
||||
string: "73 6f 6d 65",
|
||||
option: "utf8",
|
||||
}
|
||||
}).toString(),
|
||||
"QV\u0010\u0004UDWQ");
|
||||
}),
|
||||
|
||||
it("XPath expression", () => {
|
||||
assert.strictEqual(
|
||||
chef.XPathExpression("<contact-info><company>abc</company></contact-info>", {xPath: "contact-info/company"}).toString(),
|
||||
|
|
Loading…
Reference in a new issue