fix: use word-boundary regex for BRANDS detection; add Apache2 and HAProxy icons

- Switch BRANDS pass from text.includes(kw) to pre-compiled word-boundary
  regex (same (?<![a-z0-9])...(?![a-z0-9]) pattern as AUTO_SI) — fixes
  false positive where "php" matched the "hp" keyword
- Add Apache to BRANDS with aliases apache, apache2, httpd (AUTO_SI regex
  excluded apache2 because the trailing digit broke the boundary)
- Add custom ICON_HAPROXY (H-shaped path, #1489C8) — HAProxy is absent
  from simple-icons

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-23 08:15:26 +02:00
parent 1906e619b9
commit f622351983
2 changed files with 18 additions and 3 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "network-topology",
"version": "1.1.1",
"version": "1.1.2",
"scripts": {
"dev": "vite",
"build": "vite build",
+17 -2
View File
@@ -86,6 +86,12 @@ const ICON_WINDOWS = {
path: 'M0 3.449L9.75 2.1v9.451H0m10.949-9.602L24 0v11.4h-13.051M0 12.6h9.75v9.451L0 20.699M10.949 12.6H24V24l-13.051-1.8',
}
const ICON_HAPROXY = {
title: 'HAProxy',
hex: '1489C8',
path: 'M6 3v18h3v-7h6v7h3V3h-3v8H9V3H6z',
}
// ── BRANDS : alias custom, icônes absentes de simple-icons, couleurs override ─
// Les ~3000 autres icônes simple-icons sont couvertes automatiquement via AUTO_SI.
const BRANDS = [
@@ -142,6 +148,8 @@ const BRANDS = [
// Serveurs (aliases)
{ kw: ['dell', 'idrac', 'poweredge'], icon: si.siDell },
{ kw: ['hp', 'hpe', 'proliant', 'ilo', 'hewlett'], icon: si.siHp },
{ kw: ['apache', 'apache2', 'httpd'], icon: si.siApache },
{ kw: ['haproxy', 'ha-proxy'], icon: ICON_HAPROXY },
// SBC
{ kw: ['raspberry', 'raspberrypi', 'rpi', 'raspi'], icon: si.siRaspberrypi },
// Bureau (titre trop court pour l'auto-détection)
@@ -169,6 +177,13 @@ const _BRANDS_SLUGS = new Set(
BRANDS.flatMap(b => (b.icon && b.icon.slug) ? [b.icon.slug] : [])
)
// Regex pré-compilées pour chaque keyword BRANDS (mêmes frontières de mots qu'AUTO_SI)
// Évite les faux positifs de text.includes() : ex. "php" ne doit pas matcher "hp"
const _BRANDS_COMPILED = BRANDS.map(b => ({
icon: b.icon,
res: b.kw.map(kw => new RegExp('(?<![a-z0-9])' + kw.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '(?![a-z0-9])'))
}))
// Toutes les icônes simple-icons (title >= 4 chars) non couvertes par BRANDS.
// Regex pré-compilée avec frontières de mots pour éviter les faux positifs
// (ex. "known" ne doit pas matcher dans "unknown").
@@ -265,8 +280,8 @@ export function detectBrands(name, description) {
const results = []
// Pass 1 : BRANDS — aliases custom, icônes personnalisées, couleurs overridées
for (const b of BRANDS) {
if (b.kw.some(kw => text.includes(kw))) {
for (const b of _BRANDS_COMPILED) {
if (b.res.some(re => re.test(text))) {
const key = b.icon.slug ?? b.icon.title
if (!seen.has(key)) {
seen.add(key)