Skip to content

Commit 7f57e3e

Browse files
committed
fix: remove redundant MRZ formatter
1 parent 82e7c1d commit 7f57e3e

File tree

2 files changed

+2
-26
lines changed

2 files changed

+2
-26
lines changed

js/init.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { judgeCurResolution, showNotification } from "./util.js";
2-
import { createPendingPromise, extractDocumentFields, resultToHTMLElement, formatMRZ } from "./util.js";
2+
import { createPendingPromise, extractDocumentFields, resultToHTMLElement } from "./util.js";
33

44
// Promise variable used to control model loading state
55
const pDataLoad = createPendingPromise();
@@ -115,7 +115,7 @@ export const handleCapturedResult = (result, uploadedImage = null) => {
115115
parsedResultArea.innerText = "";
116116

117117
// Add MRZ Text to Result
118-
const mrzElement = resultToHTMLElement("MRZ String", formatMRZ(recognizedResults[0]?.text));
118+
const mrzElement = resultToHTMLElement("MRZ String", recognizedResults[0]?.text);
119119
mrzElement.classList.add("code");
120120
parsedResultArea.appendChild(mrzElement);
121121

js/util.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -135,30 +135,6 @@ export function resultToHTMLElement(field, value) {
135135
return p;
136136
}
137137

138-
/**
139-
* Formats a Machine Readable Zone (MRZ) string by adding line breaks based on its length.
140-
*
141-
* @param {string} [mrzString=""] - The MRZ string to format.
142-
* @returns {string} The formatted MRZ string with appropriate line breaks or the original string
143-
*/
144-
export function formatMRZ(mrzString = "") {
145-
let formattedMRZ = mrzString;
146-
147-
// Check if the length matches any known MRZ format
148-
if (mrzString.length === 88) {
149-
// Passport (TD3 format)
150-
formattedMRZ = mrzString.slice(0, 44) + "\n" + mrzString.slice(44);
151-
} else if (mrzString.length === 90) {
152-
// ID card (TD1 format)
153-
formattedMRZ = mrzString.slice(0, 30) + "\n" + mrzString.slice(30, 60) + "\n" + mrzString.slice(60);
154-
} else if (mrzString.length === 72) {
155-
// Visa (TD2 format)
156-
formattedMRZ = mrzString.slice(0, 36) + "\n" + mrzString.slice(36);
157-
}
158-
159-
return formattedMRZ;
160-
}
161-
162138
/** Check if current resolution is Full HD or HD
163139
* @params {Object} currentResolution - an object with `width` and `height` to represent the current resolution of the camera
164140
* @returns {string} Either "HD" or "Full HD" depending of the resolution of the screen

0 commit comments

Comments
 (0)