mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 07:16:17 -04:00
Tests now work
Also they'll work in the node API too now
This commit is contained in:
parent
821dd9c48c
commit
84eaaf4819
3 changed files with 10 additions and 5 deletions
|
@ -28,13 +28,14 @@ class FromMessagePack extends Operation {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {byteArray} input
|
* @param {ArrayBuffer} input
|
||||||
* @param {Object[]} args
|
* @param {Object[]} args
|
||||||
* @returns {JSON}
|
* @returns {JSON}
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
try {
|
try {
|
||||||
return notepack.decode(input);
|
const buf = Buffer.from(new Uint8Array(input));
|
||||||
|
return notepack.decode(buf);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new OperationError(`Could not decode MessagePack to JSON: ${err}`);
|
throw new OperationError(`Could not decode MessagePack to JSON: ${err}`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,10 +34,14 @@ class ToMessagePack extends Operation {
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
try {
|
try {
|
||||||
return notepack.encode(input);
|
if (ENVIRONMENT_IS_WORKER()) {
|
||||||
|
return notepack.encode(input);
|
||||||
|
} else {
|
||||||
|
return notepack.encode(input).buffer;
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new OperationError(`Could not encode JSON to MessagePack: ${err}`);
|
throw new OperationError(`Could not encode JSON to MessagePack: ${err}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,7 +350,7 @@ TestRegister.addTests([
|
||||||
{
|
{
|
||||||
name: "From MessagePack: no content",
|
name: "From MessagePack: no content",
|
||||||
input: "",
|
input: "",
|
||||||
expectedOutput: "Could not decode MessagePack to JSON: RangeError: offset is outside the bounds of the DataView",
|
expectedOutput: "Could not decode MessagePack to JSON: Error: Could not parse",
|
||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
"op": "From Hex",
|
"op": "From Hex",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue