From 282f02f4d579f408842853bccac93dc4039f2357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karsten=20Silkenb=C3=A4umer?= Date: Sat, 2 Mar 2019 22:17:44 +0100 Subject: [PATCH] Fix error when decoding a text with 2+ whitespaces in AMNZ mode --- src/core/operations/BaconCipherDecode.mjs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/operations/BaconCipherDecode.mjs b/src/core/operations/BaconCipherDecode.mjs index ecd1bc92..5d830603 100644 --- a/src/core/operations/BaconCipherDecode.mjs +++ b/src/core/operations/BaconCipherDecode.mjs @@ -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(""); }