// Website-Analyse: Angaben des Verantwortlichen fuer die Datenschutz-Zusatzseite aus dem Kundendatensatz. // Rein, ohne Imports. Einziger Regelsatz: Portal-Sperre, Portal-Vorschau und Runner-Auftrag nutzen ihn. const clean = (v) => String(v ?? '').replace(/[\x00-\x1f\x7f]/g, ' ').replace(/\s+/g, ' ').trim() const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/ /** * @returns {{ ok: boolean, company: string, address: string, email: string, missing: Array<'firma'|'email'> }} */ export function analysePrivacyData(customer) { const c = customer || {} const company = (clean(c.companyName) || clean(c.name)).slice(0, 200).trim() const address = [clean(c.street), clean(`${c.postalCode || ''} ${c.city || ''}`)].filter(Boolean).join(', ').slice(0, 300).trim() const rawEmail = clean(c.email) const email = rawEmail.slice(0, 200) const missing = [] if (!company) missing.push('firma') if (rawEmail.length > 200 || !EMAIL_RE.test(rawEmail)) missing.push('email') return { ok: missing.length === 0, company, address, email, missing } }