fix: match UGS en préfixe dans search-sheets pour les images avec suffixe (dessus, -2, etc.)
This commit is contained in:
@@ -46,7 +46,15 @@ export async function GET(req: NextRequest) {
|
||||
// col C = UGS (index 2 car on commence à A)
|
||||
const ugs = (row[2] ?? '').trim()
|
||||
|
||||
if (ugs.toLowerCase() === ref.toLowerCase() && shopifyId) {
|
||||
// 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" ✓
|
||||
const refLower = ref.toLowerCase()
|
||||
const ugsLower = ugs.toLowerCase()
|
||||
const isMatch = ugs &&
|
||||
(refLower === ugsLower ||
|
||||
(refLower.startsWith(ugsLower) && /^[-_ ]/.test(ref.slice(ugs.length))))
|
||||
|
||||
if (isMatch && shopifyId) {
|
||||
const title = (row[3] ?? '').trim() // col D = Nom
|
||||
return NextResponse.json({ found: true, shopifyId, title })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user