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:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "network-topology",
|
"name": "network-topology",
|
||||||
"version": "1.1.1",
|
"version": "1.1.2",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
|
|||||||
@@ -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',
|
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 ─
|
// ── BRANDS : alias custom, icônes absentes de simple-icons, couleurs override ─
|
||||||
// Les ~3000 autres icônes simple-icons sont couvertes automatiquement via AUTO_SI.
|
// Les ~3000 autres icônes simple-icons sont couvertes automatiquement via AUTO_SI.
|
||||||
const BRANDS = [
|
const BRANDS = [
|
||||||
@@ -142,6 +148,8 @@ const BRANDS = [
|
|||||||
// Serveurs (aliases)
|
// Serveurs (aliases)
|
||||||
{ kw: ['dell', 'idrac', 'poweredge'], icon: si.siDell },
|
{ kw: ['dell', 'idrac', 'poweredge'], icon: si.siDell },
|
||||||
{ kw: ['hp', 'hpe', 'proliant', 'ilo', 'hewlett'], icon: si.siHp },
|
{ kw: ['hp', 'hpe', 'proliant', 'ilo', 'hewlett'], icon: si.siHp },
|
||||||
|
{ kw: ['apache', 'apache2', 'httpd'], icon: si.siApache },
|
||||||
|
{ kw: ['haproxy', 'ha-proxy'], icon: ICON_HAPROXY },
|
||||||
// SBC
|
// SBC
|
||||||
{ kw: ['raspberry', 'raspberrypi', 'rpi', 'raspi'], icon: si.siRaspberrypi },
|
{ kw: ['raspberry', 'raspberrypi', 'rpi', 'raspi'], icon: si.siRaspberrypi },
|
||||||
// Bureau (titre trop court pour l'auto-détection)
|
// 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] : [])
|
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.
|
// 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
|
// Regex pré-compilée avec frontières de mots pour éviter les faux positifs
|
||||||
// (ex. "known" ne doit pas matcher dans "unknown").
|
// (ex. "known" ne doit pas matcher dans "unknown").
|
||||||
@@ -265,8 +280,8 @@ export function detectBrands(name, description) {
|
|||||||
const results = []
|
const results = []
|
||||||
|
|
||||||
// Pass 1 : BRANDS — aliases custom, icônes personnalisées, couleurs overridées
|
// Pass 1 : BRANDS — aliases custom, icônes personnalisées, couleurs overridées
|
||||||
for (const b of BRANDS) {
|
for (const b of _BRANDS_COMPILED) {
|
||||||
if (b.kw.some(kw => text.includes(kw))) {
|
if (b.res.some(re => re.test(text))) {
|
||||||
const key = b.icon.slug ?? b.icon.title
|
const key = b.icon.slug ?? b.icon.title
|
||||||
if (!seen.has(key)) {
|
if (!seen.has(key)) {
|
||||||
seen.add(key)
|
seen.add(key)
|
||||||
|
|||||||
Reference in New Issue
Block a user