fix(torob): deduplicate subtitle package size and add fresh expiry guarantee
Deploy Canina / deploy (push) Successful in 2m14s
E2E Playwright Tests / Run Full E2E & Security Suites (push) Failing after 6s

This commit is contained in:
devops committed 2026-10-14 15:48:29 +00:00
1 parent 06b8d6af23
commit 8bf1843b9b
2 files changed
+41 -13

No files matched your search

@@ -105,7 +105,7 @@ function buildTorobProductSpec(product: {
const spec: Record<string, string> = {
'برند': 'کنینا (Canina Pharma Germany)',
'کشور سازنده': 'آلمان',
'ضمانت': 'اصالت ۱۰۰٪ کالای آلمانی و سلامت فیزیکی',
'ضمانت': 'اصالت ۱۰۰٪ کالای آلمانی، سلامت فیزیکی و تاریخ انقضای به‌روز',
};
const pet = normalizeSuitableFor(product.suitableFor);
@@ -169,9 +169,25 @@ export async function GET(request: NextRequest) {
const rawEn = (product.nameEn || '').trim();
const numSize = Number(product.packageSize);
const unit = (product.unit || '').trim();
const sizeStr = numSize && numSize > 0 ? (unit ? `${numSize} ${unit}` : `${numSize}`) : '';
let subtitle = rawEn.startsWith('Canina') ? rawEn : `Canina ${rawEn}`.trim();
if (sizeStr && !subtitle.includes(sizeStr)) {
let sizeAlreadyInSubtitle = false;
if (numSize && numSize > 0) {
const escapedUnit = unit.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
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*Tab(let)?s?\\b`, 'i'),
];
sizeAlreadyInSubtitle = regexList.some((rgx) => rgx.test(subtitle));
}
if (!sizeAlreadyInSubtitle && numSize && numSize > 0) {
const sizeStr = unit ? `${numSize} ${unit}` : `${numSize}`;
subtitle = `${subtitle} - ${sizeStr}`;
}
@@ -208,7 +224,7 @@ export async function GET(request: NextRequest) {
old_price: oldPrice,
availability: isInStock ? 'instock' : 'outofstock',
image_link: imageLink,
guarantee: 'ضمانت اصالت ۱۰۰٪ کمپانی Canina آلمان و اصالت کالا',
guarantee: 'ضمانت اصالت ۱۰۰٪ کالای آلمانی، سلامت فیزیکی و تاریخ مصرف به‌روز',
category_name: catName || 'مکمل حیوانات خانگی',
spec,
};