initial sanitize function

This commit is contained in:
Bit Borealis 2023-08-19 06:03:12 +00:00
parent 70b8bb1a1a
commit 0b80911a27

View file

@ -296,13 +296,39 @@ function getInfoBits(){
return result;
}
/***
*
* Sanitize and verify qr is square before parsing it
*
***/
function sanitizeQrTxt(lines) {
const linesOut = [];
for(let i=0;i<lines.length;i++) {
if(lines[i].length !== 0) {
linesOut.push(lines[i]);
}
else {
if(i+1 === lines.length) {
return linesOut;
}
else {
throw "Unexpected empty line file."
}
}
}
}
/***
*
* Load Waidotto QR text format
* https://github.com/waidotto/strong-qr-decoder
***/
function loadTxt2Array(lines) {
function loadTxt2Array(linesIn) {
console.info(lines)
var lines = sanitizeQrTxt(linesIn);
let sz = lines.length;
var data = [];