fix: match UGS en début de nom de fichier exact (évite 30 de matcher 30827)
This commit is contained in:
@@ -46,10 +46,14 @@ 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()
|
||||||
|
|
||||||
// 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 refLower = ref.toLowerCase()
|
||||||
const ugsLower = ugs.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) {
|
if (isMatch) {
|
||||||
const title = (row[3] ?? '').trim() // col D = Nom
|
const title = (row[3] ?? '').trim() // col D = Nom
|
||||||
|
|||||||
Reference in New Issue
Block a user