1
0
mirror of synced 2024-12-15 08:21:15 +01:00

Fix error when decoding a text with 2+ whitespaces in AMNZ mode

This commit is contained in:
Karsten Silkenbäumer 2019-03-02 22:17:44 +01:00
parent d36cede0c7
commit 282f02f4d5

View File

@ -77,10 +77,14 @@ class BaconCipherDecode extends Operation {
} }
}); });
} else if (translation === BACON_TRANSLATION_AMNZ) { } else if (translation === BACON_TRANSLATION_AMNZ) {
const words = input.split(" "); const words = input.split(/\s+/);
const letters = words.map(function (e) { const letters = words.map(function (e) {
const code = e[0].toUpperCase().charCodeAt(0); if (e) {
return code >= "N".charCodeAt(0) ? "1" : "0"; const code = e[0].toUpperCase().charCodeAt(0);
return code >= "N".charCodeAt(0) ? "1" : "0";
} else {
return "";
}
}); });
input = letters.join(""); input = letters.join("");
} }