diff --git a/index.html b/index.html index fc2838f..9606abc 100644 --- a/index.html +++ b/index.html @@ -310,7 +310,15 @@ } function getName() { - const decoded = base32.decode(codeInput.value); + const input = codeInput.value.trim(); + + if (/^([01]{8}(\s|$))+/.test(input)) { + // decode binary + nameOutput.value = new TextDecoder().decode(new Int8Array(input.split(/\s+/).map((binaryLetter) => parseInt(binaryLetter, 2)))); + return; + } + + const decoded = base32.decode(input); const capitalized = decoded.split(' ').map((word) => `${word.slice(0, 1).toUpperCase()}${word.slice(1)}`).join(' '); nameOutput.value = capitalized.replace(/#+$/, '');