fix: recherche UGS par contains dans le nom de fichier (ex: 30827-dessus contient 30827)
This commit is contained in:
@@ -46,13 +46,11 @@ export async function GET(req: NextRequest) {
|
|||||||
// col C = UGS (index 2 car on commence à A)
|
// col C = UGS (index 2 car on commence à A)
|
||||||
const ugs = (row[2] ?? '').trim()
|
const ugs = (row[2] ?? '').trim()
|
||||||
|
|
||||||
// Match exact OU le ref commence par l'UGS suivi d'un séparateur
|
// Le nom de fichier contient l'UGS (ex: "30827-dessus" contient "30827")
|
||||||
// ex: "REF-1042-dessus" → UGS "REF-1042" ✓ ; "REF-1042 2" → "REF-1042" ✓
|
// Les UGS étant uniques, un simple contains suffit
|
||||||
const refLower = ref.toLowerCase()
|
const refLower = ref.toLowerCase()
|
||||||
const ugsLower = ugs.toLowerCase()
|
const ugsLower = ugs.toLowerCase()
|
||||||
const isMatch = ugs &&
|
const isMatch = ugs && refLower.includes(ugsLower)
|
||||||
(refLower === ugsLower ||
|
|
||||||
(refLower.startsWith(ugsLower) && /^[-_ ]/.test(ref.slice(ugs.length))))
|
|
||||||
|
|
||||||
if (isMatch && shopifyId) {
|
if (isMatch && shopifyId) {
|
||||||
const title = (row[3] ?? '').trim() // col D = Nom
|
const title = (row[3] ?? '').trim() // col D = Nom
|
||||||
|
|||||||
Reference in New Issue
Block a user