From 06b8d6af2345f249bd872fc69dd5f392814dcb87 Mon Sep 17 00:00:00 2001 From: devops Date: Wed, 14 Oct 2026 15:39:27 +0000 Subject: [PATCH] fix(torob): expand unit regex for package size deduplication (gr, gram, ml, tabs) --- backend/src/products/torob.controller.ts | 7 +++++-- frontend/application/app/api/torob/products/route.ts | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/backend/src/products/torob.controller.ts b/backend/src/products/torob.controller.ts index ff1eedbf..d268ad10 100644 --- a/backend/src/products/torob.controller.ts +++ b/backend/src/products/torob.controller.ts @@ -45,11 +45,14 @@ function buildTorobProductTitle(product: { const regexList = [ new RegExp(`\\b${numSize}\\s*${escapedUnit}\\b`, 'i'), new RegExp(`\\b${numSize}${escapedUnit}\\b`, 'i'), + new RegExp(`\\b${numSize}\\s*g(r|ram)?\\b`, 'i'), + new RegExp(`\\b${numSize}g(r|ram)?\\b`, 'i'), + new RegExp(`\\b${numSize}\\s*m?l\\b`, 'i'), + new RegExp(`\\b${numSize}m?l\\b`, 'i'), new RegExp(`\\b${numSize}\\s*میلی‌?لیتر\\b`, 'i'), new RegExp(`\\b${numSize}\\s*گرم\\b`, 'i'), new RegExp(`\\b${numSize}\\s*عددی?\\b`, 'i'), - new RegExp(`\\b${numSize}\\s*Tab\\b`, 'i'), - new RegExp(`\\b${numSize}\\s*tablet\\b`, 'i'), + new RegExp(`\\b${numSize}\\s*Tab(let)?s?\\b`, 'i'), ]; sizeAlreadyInNames = regexList.some((rgx) => rgx.test(nameFa) || rgx.test(nameEn)); if (!sizeAlreadyInNames) { diff --git a/frontend/application/app/api/torob/products/route.ts b/frontend/application/app/api/torob/products/route.ts index 0325055f..5669bfb1 100644 --- a/frontend/application/app/api/torob/products/route.ts +++ b/frontend/application/app/api/torob/products/route.ts @@ -48,11 +48,14 @@ function buildTorobProductTitle(product: { const regexList = [ new RegExp(`\\b${numSize}\\s*${escapedUnit}\\b`, 'i'), new RegExp(`\\b${numSize}${escapedUnit}\\b`, 'i'), + new RegExp(`\\b${numSize}\\s*g(r|ram)?\\b`, 'i'), + new RegExp(`\\b${numSize}g(r|ram)?\\b`, 'i'), + new RegExp(`\\b${numSize}\\s*m?l\\b`, 'i'), + new RegExp(`\\b${numSize}m?l\\b`, 'i'), new RegExp(`\\b${numSize}\\s*میلی‌?لیتر\\b`, 'i'), new RegExp(`\\b${numSize}\\s*گرم\\b`, 'i'), new RegExp(`\\b${numSize}\\s*عددی?\\b`, 'i'), - new RegExp(`\\b${numSize}\\s*Tab\\b`, 'i'), - new RegExp(`\\b${numSize}\\s*tablet\\b`, 'i'), + new RegExp(`\\b${numSize}\\s*Tab(let)?s?\\b`, 'i'), ]; sizeAlreadyInNames = regexList.some((rgx) => rgx.test(nameFa) || rgx.test(nameEn)); if (!sizeAlreadyInNames) {