| 1690 | } |
| 1691 | |
| 1692 | function labLogoSvg(labId: string) { |
| 1693 | const cached = LabLogoSvgs.get(labId); |
| 1694 | if (cached) return cached; |
| 1695 | |
| 1696 | const logoPath = path.join(root, "labs", labId, "logo.svg"); |
| 1697 | const defaultLogoPath = path.join(root, "providers", "logo.svg"); |
| 1698 | const rawSvg = readFileSync( |
| 1699 | existsSync(logoPath) ? logoPath : defaultLogoPath, |
| 1700 | "utf8", |
| 1701 | ); |
| 1702 | const svg = rawSvg |
| 1703 | .replace(/<svg\b([^>]*)>/i, (_, attributes: string) => { |
| 1704 | const cleaned = attributes.replace(/\s(width|height)="[^"]*"/gi, ""); |
| 1705 | return `<svg${cleaned} aria-hidden="true" focusable="false">`; |
| 1706 | }) |
| 1707 | .replace(/\sfill="(?!none)[^"]*"/gi, ' fill="currentColor"') |
| 1708 | .replace(/\sstroke="(?!none)[^"]*"/gi, ' stroke="currentColor"'); |
| 1709 | |
| 1710 | LabLogoSvgs.set(labId, svg); |
| 1711 | return svg; |
| 1712 | } |