fix: match UGS comme mot entier n'importe où dans le nom de fichier
This commit is contained in:
@@ -46,14 +46,12 @@ export async function GET(req: NextRequest) {
|
||||
// col C = UGS (index 2 car on commence à A)
|
||||
const ugs = (row[2] ?? '').trim()
|
||||
|
||||
// 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"
|
||||
// L'UGS doit apparaître comme mot entier dans le nom de fichier
|
||||
// (entouré de séparateurs ou en début/fin) — ex: "dessus-30827-vue" ✓, "308270" ✗
|
||||
const refLower = ref.toLowerCase()
|
||||
const ugsLower = ugs.toLowerCase()
|
||||
const isMatch = ugs && shopifyId && (
|
||||
refLower === ugsLower ||
|
||||
refLower.startsWith(ugsLower) && /^[-_. ]/.test(ref.slice(ugs.length))
|
||||
)
|
||||
const wordBoundary = new RegExp(`(^|[^a-z0-9])${ugsLower.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}([^a-z0-9]|$)`)
|
||||
const isMatch = ugs && shopifyId && wordBoundary.test(refLower)
|
||||
|
||||
if (isMatch) {
|
||||
const title = (row[3] ?? '').trim() // col D = Nom
|
||||
|
||||
Reference in New Issue
Block a user