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
1 changed files with 7 additions and 3 deletions

View File

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