Files
Visigine/server/lib/parser.js
Ihor_Zhekov e344f1b7e7 Initial commit: Visigine (Vite client + Express/SQLite backend)
Container-ready via docker/ compose (frontend nginx + backend Node). Compose adjusted for Coolify on the prod server: frontend uses expose:80 (no host binding — host 8080 is taken by the Coolify proxy; Traefik routes visigine.de), backend ALLOWED_ORIGINS=https://visigine.de. Secrets stay in server/.env (git-ignored); see server/.env.example.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 10:15:06 +02:00

17 lines
541 B
JavaScript

// Extracts the parts of the HTML response that downstream checks need.
export function parseHtml(html) {
const safe = html || ''
const headMatch = safe.match(/<head[\s\S]*?<\/head>/i)
const headHtml = headMatch ? headMatch[0] : safe.slice(0, 4000)
const jsonLdBlocks = [
...safe.matchAll(/<script[^>]*type=["']application\/ld\+json["'][^>]*>([\s\S]*?)<\/script>/gi),
]
.map((m) => m[1].trim())
.filter(Boolean)
const jsonLdJoined = jsonLdBlocks.join('\n---\n')
return { headHtml, jsonLdBlocks, jsonLdJoined }
}