From e20bb6cb45e8e14fc5f576f99be9f08db68dc434 Mon Sep 17 00:00:00 2001 From: Rene Fichtmueller Date: Tue, 21 Apr 2026 00:45:41 +0200 Subject: [PATCH] fix: MikroTik hardcoded slug map for + models (crs305/312/317/326) --- .../src/scrapers/switch-image-fetcher.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/scraper/src/scrapers/switch-image-fetcher.ts b/packages/scraper/src/scrapers/switch-image-fetcher.ts index cb7c5d5..0b8885c 100644 --- a/packages/scraper/src/scrapers/switch-image-fetcher.ts +++ b/packages/scraper/src/scrapers/switch-image-fetcher.ts @@ -124,10 +124,25 @@ function buildExtremeUrl(model: string): string | null { return `https://www.extremenetworks.com/product/${slug}/`; } +// MikroTik product URL slugs for models containing '+' are not derivable from +// the model name — their website uses opaque suffixes (_in, _rm, …). +// The models without '+' follow a simple pattern (lowercase, dashes→underscore). +const MIKROTIK_SLUG_MAP: Record = { + "CRS305-1G-4S+": "crs305_1g_4s_in", + "CRS312-4C+8XG": "crs312_4c_8xg_rm", + "CRS317-1G-16S+": "crs317_1g_16s_rm", + "CRS326-24G-2S+": "crs326_24g_2s_in", + // CRS354-48G-4S+2Q+: URL not discoverable — MikroTik's product listing is JS-rendered +}; + function buildMikroTikUrl(model: string): string | null { - // CRS504-4XQ-IN → https://mikrotik.com/product/crs504_4xq_in (lowercase required) + if (model in MIKROTIK_SLUG_MAP) { + return `https://mikrotik.com/product/${MIKROTIK_SLUG_MAP[model]}`; + } + if (model.includes("+")) return null; // other + models — URL unknown + // Simple lowercase + dashes→underscores for models without '+' const slug = model.toLowerCase().replace(/[-\s]+/g, "_").replace(/[^a-z0-9_]/g, ""); - return `https://mikrotik.com/product/${slug}`; + return slug ? `https://mikrotik.com/product/${slug}` : null; } function buildUbiquitiUrl(model: string): string | null {