Added BRC_BW_FORMAT_UNSUPPORTED to not let PKBarcodeFormatCode128 to be used as backward barcode format

This commit is contained in:
Alexander Cerutti
2019-04-04 23:09:01 +02:00
parent 2bdd906989
commit f7d0823528
2 changed files with 16 additions and 1 deletions

View File

@@ -411,7 +411,16 @@ class Pass {
}, []);
if (valid.length) {
this._props["barcode"] = valid[0];
// With this check, we want to avoid that
// PKBarcodeFormatCode128 gets chosen automatically
// if it is the first. If true, we'll get 1
// (so not the first index)
let barcodeFirstValidIndex = Number(valid[0].format === "PKBarcodeFormatCode128");
if (valid.length > 1) {
this._props["barcode"] = valid[barcodeFirstValidIndex];
}
this._props["barcodes"] = valid;
}
@@ -469,6 +478,11 @@ class Pass {
return this;
}
if (format === "PKBarcodeFormatCode128") {
barcodeDebug(formatMessage("BRC_BW_FORMAT_UNSUPPORTED"));
return this;
}
// Checking which object among barcodes has the same format of the specified one.
let index = this._props["barcodes"].findIndex(b => b.format.toLowerCase().includes(format.toLowerCase()));