File tree Expand file tree Collapse file tree 2 files changed +2
-26
lines changed Expand file tree Collapse file tree 2 files changed +2
-26
lines changed Original file line number Diff line number Diff line change 11import { 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
55const 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments