mirror of
https://github.com/Merricx/qrazybox.git
synced 2025-04-19 17:49:04 +02:00
initial sanitize function
This commit is contained in:
parent
70b8bb1a1a
commit
0b80911a27
1 changed files with 27 additions and 1 deletions
28
js/main.js
28
js/main.js
|
@ -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 = [];
|
||||
|
|
Loading…
Add table
Reference in a new issue