From c19510d413be50850a91708b28f3edfe8f93b471 Mon Sep 17 00:00:00 2001 From: Mathieu Date: Thu, 11 Jun 2026 12:47:26 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20match=20UGS=20en=20d=C3=A9but=20de=20nom?= =?UTF-8?q?=20de=20fichier=20exact=20(=C3=A9vite=2030=20de=20matcher=20308?= =?UTF-8?q?27)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/api/products/search-sheets/route.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/api/products/search-sheets/route.ts b/src/app/api/products/search-sheets/route.ts index 6efbcb5..a72b9b7 100644 --- a/src/app/api/products/search-sheets/route.ts +++ b/src/app/api/products/search-sheets/route.ts @@ -46,10 +46,14 @@ export async function GET(req: NextRequest) { // col C = UGS (index 2 car on commence à A) const ugs = (row[2] ?? '').trim() - // Le nom de fichier contient l'UGS (ex: "30827-dessus" contient "30827") + // L'UGS doit correspondre exactement au début du nom de fichier, + // suivi d'un séparateur (-_. espace) ou de la fin — évite "30" de matcher "30827" const refLower = ref.toLowerCase() const ugsLower = ugs.toLowerCase() - const isMatch = ugs && shopifyId && refLower.includes(ugsLower) + const isMatch = ugs && shopifyId && ( + refLower === ugsLower || + refLower.startsWith(ugsLower) && /^[-_. ]/.test(ref.slice(ugs.length)) + ) if (isMatch) { const title = (row[3] ?? '').trim() // col D = Nom