fix: recherche UGS par contains dans le nom de fichier (ex: 30827-dessus contient 30827)

This commit is contained in:
2026-06-10 09:38:16 +02:00
parent da52080e3e
commit 6a08fccb7a
+3 -5
View File
@@ -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