mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 22:25:24 +00:00
Added BRC_BW_FORMAT_UNSUPPORTED to not let PKBarcodeFormatCode128 to be used as backward barcode format
This commit is contained in:
@@ -15,6 +15,7 @@ const debugMessages = {
|
||||
BRC_NOT_SUPPORTED: "Format not found among barcodes. Cannot set backward compatibility.",
|
||||
BRC_FORMATTYPE_UNMATCH: "Format must be a string or null. Cannot set backward compatibility.",
|
||||
BRC_AUTC_MISSING_DATA: "Unable to autogenerate barcodes. Data is not a string or an object with no message field",
|
||||
BRC_BW_FORMAT_UNSUPPORTED: "This format is not supported (by Apple) for backward support. Please choose another one.",
|
||||
DATE_FORMAT_UNMATCH: "%s was not set due to incorrect date format.",
|
||||
LOAD_TYPES_UNMATCH: "Resource and name are not valid strings. No action will be taken for the specified medias.",
|
||||
LOAD_MIME: "Picture MIME-type: %s",
|
||||
|
||||
16
src/pass.js
16
src/pass.js
@@ -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()));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user