From 6a08fccb7ad5d94a9a31990470470a905bf1dc2a Mon Sep 17 00:00:00 2001 From: Mathieu Date: Wed, 10 Jun 2026 09:38:16 +0200 Subject: [PATCH] fix: recherche UGS par contains dans le nom de fichier (ex: 30827-dessus contient 30827) --- src/app/api/products/search-sheets/route.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/app/api/products/search-sheets/route.ts b/src/app/api/products/search-sheets/route.ts index 3f96fbc..1ee22a1 100644 --- a/src/app/api/products/search-sheets/route.ts +++ b/src/app/api/products/search-sheets/route.ts @@ -46,13 +46,11 @@ export async function GET(req: NextRequest) { // col C = UGS (index 2 car on commence à A) const ugs = (row[2] ?? '').trim() - // Match exact OU le ref commence par l'UGS suivi d'un séparateur - // ex: "REF-1042-dessus" → UGS "REF-1042" ✓ ; "REF-1042 2" → "REF-1042" ✓ + // Le nom de fichier contient l'UGS (ex: "30827-dessus" contient "30827") + // Les UGS étant uniques, un simple contains suffit const refLower = ref.toLowerCase() const ugsLower = ugs.toLowerCase() - const isMatch = ugs && - (refLower === ugsLower || - (refLower.startsWith(ugsLower) && /^[-_ ]/.test(ref.slice(ugs.length)))) + const isMatch = ugs && refLower.includes(ugsLower) if (isMatch && shopifyId) { const title = (row[3] ?? '').trim() // col D = Nom