From d89d202f28587a09c96faaf4de932e20542dfb4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Seshanth=2ES=F0=9F=90=BA?= <35675963+seshanthS@users.noreply.github.com> Date: Thu, 19 Jun 2025 13:52:00 +0530 Subject: [PATCH] fix: update TD1 and TD3 checks (#643) --- app/src/utils/utils.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/utils/utils.ts b/app/src/utils/utils.ts index 5580c79a1..8291a6b63 100644 --- a/app/src/utils/utils.ts +++ b/app/src/utils/utils.ts @@ -2,9 +2,13 @@ export function extractMRZInfo(mrzString: string) { const mrzLines = mrzString.split('\n'); - // Check format based on line length - const isTD1 = mrzLines[0].length === 30 || mrzLines[0].startsWith('ID'); - const isTD3 = mrzLines[0].length === 44; + //line 1 and line 2 - concated + const TD1_REGEX = + /^(?[A-Z0-9<]{2})(?[A-Z<]{3})(?[A-Z0-9<]{9})(?[0-9]{1})(?[A-Z0-9<]{15})(?[0-9]{6})(?[0-9]{1})(?[MF<]{1})(?[0-9]{6})(?[0-9]{1})(?[A-Z<]{3})(?[A-Z0-9<]{7})/; + const TD3_line_2_REGEX = /^([A-Z0-9<]{9})([0-9ILDSOG])([A-Z<]{3})/; + + const isTD1 = TD1_REGEX.test(mrzLines[0]) || mrzLines[0].startsWith('I'); + const isTD3 = TD3_line_2_REGEX.test(mrzLines[1]); if (!isTD1 && !isTD3) { throw new Error(