From f135c12785c35bc36e3c5adba900d3c2939e7a4e Mon Sep 17 00:00:00 2001 From: Ruslan Bakiev <572431+veikab@users.noreply.github.com> Date: Tue, 31 Mar 2026 12:31:45 +0700 Subject: [PATCH] Fix catalog parser for anchor attribute order --- scripts/seed.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/seed.js b/scripts/seed.js index 7a0e74d..bd23a86 100644 --- a/scripts/seed.js +++ b/scripts/seed.js @@ -35,14 +35,18 @@ function skuFromHref(href, index) { function parseCatalogCards(html) { const cards = []; - const cardRegex = - /]*class="[^"]*product-card[^"]*"[^>]*href="([^"]+)"[^>]*>[\s\S]*?
([\s\S]*?)<\/div>\s*
([\s\S]*?)<\/div>/g; + const cardRegex = /]*)class="[^"]*product-card[^"]*"([^>]*)>([\s\S]*?)<\/a>/g; let match; while ((match = cardRegex.exec(html)) !== null) { - const href = match[1]; - const title = normalizeText(match[2]); - const type = normalizeText(match[3]); + const attrs = `${match[1]} ${match[2]}`; + const body = match[3]; + const hrefMatch = attrs.match(/href="([^"]+)"/); + const titleMatch = body.match(/
([\s\S]*?)<\/div>/); + const typeMatch = body.match(/
([\s\S]*?)<\/div>/); + const href = hrefMatch?.[1] ?? ''; + const title = normalizeText(titleMatch?.[1] ?? ''); + const type = normalizeText(typeMatch?.[1] ?? ''); if (!title) { continue; }