sitecheckultra 2.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # 🚀 Site Check Ultra
2
2
 
3
- **Der schnelle Website-Audit für SEO, Speed, Mobile & WCAG**
3
+ **Der schnelle Website-Audit für SEO, Speed, Mobile & WCAG 2.2**
4
4
 
5
- Ein lokales Tool zum Crawlen und Analysieren von Websites. Prüft Indexierung, Canonicals, Redirects, H-Baum, Schema, Tracking, Links, Geschwindigkeit, Mobile-Optimierung und Barrierefreiheit.
5
+ Ein lokales Tool zum Crawlen und Analysieren von Websites. Prüft Indexierung, Canonicals, Redirects, H-Baum, Schema, Tracking, Links, Geschwindigkeit, Mobile-Optimierung und Barrierefreiheit nach WCAG 2.2 (W3C Recommendation).
6
6
 
7
- ![Site Check Ultra](https://img.shields.io/badge/version-2.0.0-blue)
7
+ ![Site Check Ultra](https://img.shields.io/badge/version-2.1.0-blue)
8
8
  ![Node.js](https://img.shields.io/badge/node-%3E%3D18.0.0-green)
9
9
  ![License](https://img.shields.io/badge/license-MIT-blue)
10
10
 
@@ -28,7 +28,7 @@ Das war's! Der Server startet automatisch und öffnet deinen Browser.
28
28
  - **Hygiene (15%)** – Redirects, Broken Links, Tracking
29
29
  - **Speed (15%)** – TTFB, Payload-Größe, External Scripts
30
30
  - **Mobile (15%)** – Viewport, Responsive Images, Touch Icons
31
- - **WCAG (15%)** – Alt-Texte, Überschriften, Link-Texte
31
+ - **WCAG 2.2 (15%)** – lang, Alt-Attribute, Überschriften, Linktexte/Namen, iframe-title, main, tabindex
32
32
 
33
33
  ### 🎯 **Multi-Core Crawler**
34
34
  - Sitemap-Erkennung
@@ -71,6 +71,21 @@ sitecheckultra
71
71
  npx sitecheckultra
72
72
  ```
73
73
 
74
+ ### Entwicklung / Update von GitHub
75
+
76
+ Immer die aktuelle Entwicklungsversion (ohne npm OTP):
77
+
78
+ ```bash
79
+ # Im Projektordner – CLI zeigt auf diesen Code
80
+ npm link
81
+
82
+ # Oder global von GitHub installieren
83
+ npm install -g github:iamthamanic/sitecheckultra
84
+
85
+ # Einmalig ohne Installation
86
+ npx github:iamthamanic/sitecheckultra
87
+ ```
88
+
74
89
  ---
75
90
 
76
91
  ## 🚀 Verwendung
@@ -153,8 +168,8 @@ MIT © Site Check Ultra
153
168
 
154
169
  ## 🔗 Links
155
170
 
156
- - **GitHub**: https://github.com/yourusername/site-check-ultra
157
- - **Issues**: https://github.com/yourusername/site-check-ultra/issues
171
+ - **GitHub**: https://github.com/iamthamanic/sitecheckultra
172
+ - **Issues**: https://github.com/iamthamanic/sitecheckultra/issues
158
173
  - **npm**: https://www.npmjs.com/package/sitecheckultra
159
174
 
160
175
  ---
@@ -11,7 +11,7 @@ import { spawn, execSync } from 'node:child_process';
11
11
  import { createRequire } from 'node:module';
12
12
  import { fileURLToPath } from 'node:url';
13
13
  import { dirname, join, sep } from 'node:path';
14
- import { existsSync } from 'node:fs';
14
+ import { existsSync, lstatSync } from 'node:fs';
15
15
  import https from 'node:https';
16
16
 
17
17
  const __filename = fileURLToPath(import.meta.url);
@@ -21,6 +21,7 @@ const require = createRequire(import.meta.url);
21
21
  // Konfiguration
22
22
  const PACKAGE_NAME = 'sitecheckultra';
23
23
  const DEFAULT_PORT = 3456;
24
+ const PACKAGE_ROOT = join(__dirname, '..');
24
25
 
25
26
  // Farben für Console-Output
26
27
  const colors = {
@@ -43,6 +44,49 @@ function currentVersion() {
43
44
  }
44
45
  }
45
46
 
47
+ /**
48
+ * True wenn die globale Installation ein Symlink auf diesen Ordner ist (npm link),
49
+ * oder wenn wir direkt aus einem Git-Checkout außerhalb von node_modules starten.
50
+ * import.meta.url ist bereits realpath — daher globalen node_modules-Eintrag prüfen.
51
+ */
52
+ function isLinkedInstall() {
53
+ try {
54
+ const globalPkg = join(
55
+ execSync('npm prefix -g', { encoding: 'utf8' }).trim(),
56
+ 'lib',
57
+ 'node_modules',
58
+ PACKAGE_NAME
59
+ );
60
+ if (existsSync(globalPkg) && lstatSync(globalPkg).isSymbolicLink()) {
61
+ return true;
62
+ }
63
+ } catch {
64
+ // npm prefix kann fehlschlagen – Fallback unten
65
+ }
66
+ try {
67
+ // Direkt aus Repo starten (node bin/…), nicht aus …/node_modules/sitecheckultra/…
68
+ const norm = PACKAGE_ROOT.replace(/\\/g, '/');
69
+ return !norm.includes(`/node_modules/${PACKAGE_NAME}`);
70
+ } catch {
71
+ return false;
72
+ }
73
+ }
74
+
75
+ /** SemVer a > b (nur Ziffern-Teile; Pre-Release ignoriert). */
76
+ function isNewerVersion(a, b) {
77
+ const parse = (v) => String(v || '0').split('-')[0].split('.').map((n) => parseInt(n, 10) || 0);
78
+ const aa = parse(a);
79
+ const bb = parse(b);
80
+ const len = Math.max(aa.length, bb.length);
81
+ for (let i = 0; i < len; i++) {
82
+ const x = aa[i] || 0;
83
+ const y = bb[i] || 0;
84
+ if (x > y) return true;
85
+ if (x < y) return false;
86
+ }
87
+ return false;
88
+ }
89
+
46
90
  function log(message, color = colors.reset) {
47
91
  console.log(`${color}${message}${colors.reset}`);
48
92
  }
@@ -106,23 +150,38 @@ function checkForUpdates() {
106
150
  const latest = JSON.parse(data);
107
151
  const current = currentVersion();
108
152
 
109
- if (latest.version && latest.version !== current) {
153
+ // Nur echte Upgrades (SemVer), nie Downgrade wenn lokal neuer (z.B. 2.1.0 > npm 2.0.3).
154
+ // npm link / Dev-Checkout: nie auto `npm install -g` — sonst wird die Link-Kette zerstört.
155
+ if (latest.version && isNewerVersion(latest.version, current)) {
110
156
  const updateCmd = 'npm install -g sitecheckultra@latest';
157
+ const linked = isLinkedInstall();
111
158
  log('');
112
159
  log('╔════════════════════════════════════════════════════════╗', colors.yellow);
113
160
  log('║ 🎉 Neue Version verfügbar! ║', colors.yellow);
114
161
  log(`║ Aktuell: ${current.padEnd(10)} → Neu: ${latest.version.padEnd(10)} ║`, colors.yellow);
115
162
  log('║ ║', colors.yellow);
116
- log(`║ Update mit: ${updateCmd.padEnd(41)}║`, colors.bright + colors.yellow);
163
+ if (linked) {
164
+ log('║ Dev-Link aktiv – Auto-Update übersprungen. ║', colors.yellow);
165
+ log('║ Update: git pull oder npm install -g github:… ║', colors.bright + colors.yellow);
166
+ } else {
167
+ log(`║ Update mit: ${updateCmd.padEnd(41)}║`, colors.bright + colors.yellow);
168
+ }
117
169
  log('╚════════════════════════════════════════════════════════╝', colors.yellow);
118
170
  log('');
119
171
 
120
- // npx-Lauf (npx scu / npx sitecheckultra): automatisch auf die
121
- // neue Version heben und danach die GLOBALE Installation starten
122
- // (npm install -g ersetzt die Dateien; der npx-Cache-Code bleibt alt).
123
- const runningViaNpx = String(process.argv[1] || '').includes(`${sep}_npx${sep}`);
124
- if (runningViaNpx) {
125
- log('ℹ npx-Lauf erkannt – starte Update auf die neueste Version…', colors.cyan);
172
+ // Auto-Update bei JEDEM Start (npx ODER globale Installation),
173
+ // außer SCU_NO_UPDATE=1 oder npm-link/Dev. Nach erfolgreichem Update
174
+ // startet dieser Prozess die neue globale Binärversion als Kind
175
+ // und beendet sich selbst (sonst zwei Server auf verschiedenen Ports).
176
+ if (linked || process.env.SCU_NO_UPDATE === '1') {
177
+ log(
178
+ linked
179
+ ? 'ℹ Dev-Link: Registry-Update übersprungen (läuft lokal).'
180
+ : 'ℹ Update-Prüfung übersprungen (SCU_NO_UPDATE=1).',
181
+ colors.dim
182
+ );
183
+ } else {
184
+ log(`ℹ Neue Version gefunden – update automatisch auf ${latest.version}…`, colors.cyan);
126
185
  try {
127
186
  execSync(updateCmd, { stdio: 'inherit' });
128
187
  log('✓ Update installiert – starte neue Version…', colors.green);
@@ -130,6 +189,9 @@ function checkForUpdates() {
130
189
  const globalBin = process.platform === 'win32'
131
190
  ? join(globalPrefix, 'sitecheckultra.cmd')
132
191
  : join(globalPrefix, 'bin', 'sitecheckultra');
192
+ if (!existsSync(globalBin)) {
193
+ throw new Error(`Globale Binärdatei nach Update nicht gefunden: ${globalBin}`);
194
+ }
133
195
  const child = spawn(process.execPath, [globalBin], {
134
196
  env: { ...process.env, SITECHECK_UPDATED: String(latest.version) },
135
197
  stdio: 'inherit'
@@ -137,7 +199,7 @@ function checkForUpdates() {
137
199
  child.on('exit', (code) => process.exit(code || 0));
138
200
  process.on('SIGINT', () => { child.kill('SIGINT'); process.exit(0); });
139
201
  process.on('SIGTERM', () => { child.kill('SIGTERM'); process.exit(0); });
140
- resolve(true);
202
+ resolve('replaced');
141
203
  return;
142
204
  } catch (err) {
143
205
  log(`⚠ Auto-Update fehlgeschlagen: ${err.message}`, colors.yellow);
@@ -213,6 +275,8 @@ async function findFreePort(startPort = DEFAULT_PORT) {
213
275
  * Öffnet den Browser
214
276
  */
215
277
  function openBrowser(url) {
278
+ // SCU_NO_BROWSER=1 unterdrückt das Browser-Öffnen (z. B. für Tests/CI).
279
+ if (process.env.SCU_NO_BROWSER === '1') return;
216
280
  const platform = process.platform;
217
281
  let command;
218
282
 
@@ -335,8 +399,14 @@ async function main() {
335
399
  // 1. Node.js Version prüfen
336
400
  checkNodeVersion();
337
401
 
338
- // 2. Auf Updates prüfen (asynchron, blockiert nicht)
339
- checkForUpdates();
402
+ // 2. Auf Updates prüfen und ggf. automatisch aktualisieren. Wird hier
403
+ // bewusst GEWARTET (statt parallel), damit nach einem Auto-Update nicht
404
+ // parallel ein alter Server auf einem anderen Port hochfährt.
405
+ const updateResult = await checkForUpdates();
406
+ if (updateResult === 'replaced') {
407
+ // Die neue Version läuft als Kindprozess weiter — hier nichts mehr tun.
408
+ return;
409
+ }
340
410
 
341
411
  // 3. Server starten
342
412
  await startServer();
package/lib/analyzer.js CHANGED
@@ -1,4 +1,11 @@
1
1
  import { Parser } from 'htmlparser2';
2
+ import {
3
+ formatHttpStatusError,
4
+ formatNetworkError,
5
+ formatNonHtmlError,
6
+ formatRedirectLoopError,
7
+ humanizeCrawlErrorMessage
8
+ } from './crawl-error.js';
2
9
  import { fastFetch } from './http-client.js';
3
10
  import { scorePage } from './scorer.js';
4
11
  import { buildAuthHeaders, canonicalCompareKey, normalizeUrl } from './sitemap.js';
@@ -7,8 +14,28 @@ import { detectTrackers } from './trackers.js';
7
14
  const SPA_HINT_REGEX = /id=["'](?:root|app|__next|__nuxt)["']|data-reactroot|type=["']module["']|_next\/static|_nuxt\/|chunk|bundle/i;
8
15
  const H_TAG_REGEX = /^h([1-9]\d*)$/i;
9
16
  const WS_COLLAPSE_REGEX = /\s+/g;
10
- // Link texts that give screen readers no clue about the destination (WCAG 2.4.4)
17
+ // Link texts that give screen readers no clue about the destination (WCAG 2.2 SC 2.4.4)
11
18
  const GENERIC_LINK_TEXT_REGEX = /^(hier|mehr|weiter|weiterlesen|mehr erfahren|mehr info|infos|info|details|click|klick|link|lesen|hier klicken|hier gehts|hier geht's|hier!\.?|mehr…|…|\*|→|»|>\s*$)$/i;
19
+ const TRACKING_PIXEL_SRC_REGEX = /(?:pixel|beacon|track(?:ing)?|analytics|spacer|1x1|transparent\.gif|blank\.gif)/i;
20
+
21
+ /** WCAG 2.2 SC 1.1.1: images that need no descriptive alt (decorative / already labelled / tracking pixels). */
22
+ function isExemptFromAltRequirement(attribs, src = '') {
23
+ const ariaHidden = (attribs['aria-hidden'] || '').toLowerCase();
24
+ if (ariaHidden === 'true') return true;
25
+
26
+ const role = (attribs.role || '').toLowerCase();
27
+ if (role === 'presentation' || role === 'none') return true;
28
+
29
+ if ((attribs['aria-label'] || '').trim() || (attribs['aria-labelledby'] || '').trim()) return true;
30
+
31
+ const w = parseInt(attribs.width, 10);
32
+ const h = parseInt(attribs.height, 10);
33
+ if ((w === 0 || w === 1) && (h === 0 || h === 1)) return true;
34
+
35
+ if (src && TRACKING_PIXEL_SRC_REGEX.test(src)) return true;
36
+
37
+ return false;
38
+ }
12
39
 
13
40
  export async function fetchWithRedirects(url, auth = null, timeoutMs = 25000, maxHops = 10) {
14
41
  const started = Date.now();
@@ -37,6 +64,23 @@ export async function fetchWithRedirects(url, auth = null, timeoutMs = 25000, ma
37
64
  location: nextUrl
38
65
  });
39
66
  await response.body?.cancel().catch(() => {});
67
+
68
+ // Last allowed hop still redirects → treat as redirect loop / too many hops
69
+ if (hop >= maxHops) {
70
+ return {
71
+ initialUrl: url,
72
+ finalUrl: currentUrl,
73
+ initialStatus: redirectChain[0]?.status || status,
74
+ finalStatus: 0,
75
+ redirectChain,
76
+ contentType: '',
77
+ headers: {},
78
+ html: '',
79
+ responseTimeMs: Date.now() - started,
80
+ error: formatRedirectLoopError(redirectChain.length)
81
+ };
82
+ }
83
+
40
84
  currentUrl = nextUrl;
41
85
  continue;
42
86
  }
@@ -55,10 +99,17 @@ export async function fetchWithRedirects(url, auth = null, timeoutMs = 25000, ma
55
99
  };
56
100
 
57
101
  let html = '';
102
+ let fetchError = null;
58
103
  if (contentType.includes('text/html') || contentType.includes('application/xhtml+xml') || contentType === '') {
59
104
  html = await response.text();
60
105
  } else {
61
106
  await response.body?.cancel().catch(() => {});
107
+ fetchError = formatNonHtmlError(contentType);
108
+ }
109
+
110
+ // Auth / forbidden without usable HTML → concrete HTTP reason
111
+ if (!fetchError && (finalStatus === 401 || finalStatus === 403) && !html) {
112
+ fetchError = formatHttpStatusError(finalStatus);
62
113
  }
63
114
 
64
115
  return {
@@ -71,7 +122,7 @@ export async function fetchWithRedirects(url, auth = null, timeoutMs = 25000, ma
71
122
  headers: rawHeaders,
72
123
  html,
73
124
  responseTimeMs: Date.now() - started,
74
- error: null
125
+ error: fetchError
75
126
  };
76
127
  } catch (err) {
77
128
  return {
@@ -84,7 +135,7 @@ export async function fetchWithRedirects(url, auth = null, timeoutMs = 25000, ma
84
135
  headers: {},
85
136
  html: '',
86
137
  responseTimeMs: Date.now() - started,
87
- error: err.name === 'TimeoutError' ? 'Timeout' : (err.message || 'Netzwerkfehler')
138
+ error: formatNetworkError(err, { timeoutMs }) || 'Netzwerkfehler'
88
139
  };
89
140
  }
90
141
  }
@@ -240,6 +291,14 @@ function parseHtmlSax(html, finalUrl, origin) {
240
291
  let siteLogo = '';
241
292
  let genericLinkTextCount = 0;
242
293
 
294
+ // WCAG 2.2 HTML signals (static crawl – no browser a11y engine)
295
+ let emptyAccessibleLinkCount = 0;
296
+ let iframeMissingTitleCount = 0;
297
+ let positiveTabindexCount = 0;
298
+ let hasMainLandmark = false;
299
+ // Stack for every <a href> (independent of URL-deduped link maps) to judge accessible names
300
+ const a11yLinkStack = [];
301
+
243
302
  const countWordsInChunk = (txt) => {
244
303
  let inWord = false;
245
304
  for (let i = 0; i < txt.length; i++) {
@@ -265,6 +324,26 @@ function parseHtmlSax(html, finalUrl, origin) {
265
324
  nonTextDepth += 1;
266
325
  }
267
326
 
327
+ // WCAG 2.2: positive tabindex risks focus order (SC 2.4.3)
328
+ if (attribs.tabindex !== undefined) {
329
+ const ti = Number.parseInt(String(attribs.tabindex).trim(), 10);
330
+ if (Number.isFinite(ti) && ti > 0) positiveTabindexCount += 1;
331
+ }
332
+
333
+ // WCAG 2.2: main landmark helps bypass blocks / structure (SC 1.3.1 / 2.4.1)
334
+ if (!hasMainLandmark) {
335
+ if (name === 'main') hasMainLandmark = true;
336
+ else if ((attribs.role || '').toLowerCase() === 'main') hasMainLandmark = true;
337
+ }
338
+
339
+ // WCAG 2.2 SC 4.1.2: iframe needs accessible name (title / aria-label)
340
+ if (name === 'iframe' || name === 'frame') {
341
+ const iframeTitle = (attribs.title || '').trim();
342
+ const iframeAria = (attribs['aria-label'] || '').trim();
343
+ const iframeHidden = (attribs['aria-hidden'] || '').toLowerCase() === 'true';
344
+ if (!iframeHidden && !iframeTitle && !iframeAria) iframeMissingTitleCount += 1;
345
+ }
346
+
268
347
  if (name === 'html' && !lang && attribs.lang) {
269
348
  lang = attribs.lang.trim();
270
349
  } else if (name === 'body') {
@@ -317,13 +396,19 @@ function parseHtmlSax(html, finalUrl, origin) {
317
396
  }
318
397
  if (attribs.srcset || attribs.sourceset) srcsetImgCount += 1;
319
398
  const alt = attribs.alt;
320
- if (alt === undefined) {
399
+ const imgSrc = attribs.src || attribs['data-src'] || '';
400
+ // WCAG 2.2 SC 1.1.1: only flag missing alt. Empty alt="" = decorative (OK).
401
+ // Also skip when aria-hidden / presentation / aria-label cover the image, or 1×1 tracking pixels.
402
+ if (alt === undefined && !isExemptFromAltRequirement(attribs, imgSrc)) {
321
403
  if (imagesMissingAlt.length < 50) {
322
- imagesMissingAlt.push({ src: attribs.src || attribs['data-src'] || '', reason: 'missing' });
404
+ imagesMissingAlt.push({ src: imgSrc, reason: 'missing' });
323
405
  }
324
- } else if (alt.trim() === '') {
325
- if (imagesMissingAlt.length < 50) {
326
- imagesMissingAlt.push({ src: attribs.src || attribs['data-src'] || '', reason: 'empty' });
406
+ }
407
+ // Img alt / aria-label can provide the accessible name for a wrapping link (SC 2.4.4 / 4.1.2)
408
+ if (a11yLinkStack.length > 0) {
409
+ const linkTop = a11yLinkStack[a11yLinkStack.length - 1];
410
+ if ((alt && alt.trim()) || (attribs['aria-label'] || '').trim()) {
411
+ linkTop.hasImgName = true;
327
412
  }
328
413
  }
329
414
  // Fallback alt text for headings that wrap an <img>
@@ -337,6 +422,18 @@ function parseHtmlSax(html, finalUrl, origin) {
337
422
  }
338
423
  } else if (name === 'a' && attribs.href && ignoreHeadingDepth === 0) {
339
424
  const rawHref = attribs.href.trim();
425
+ // WCAG 2.2: track every href link for empty accessible name (incl. #anchors)
426
+ if (rawHref) {
427
+ a11yLinkStack.push({
428
+ depth: 1,
429
+ text: '',
430
+ ariaLabel: (attribs['aria-label'] || '').trim(),
431
+ ariaLabelledby: (attribs['aria-labelledby'] || '').trim(),
432
+ title: (attribs.title || '').trim(),
433
+ hasImgName: false,
434
+ ariaHidden: (attribs['aria-hidden'] || '').toLowerCase() === 'true'
435
+ });
436
+ }
340
437
  if (rawHref && rawHref.charCodeAt(0) !== 35 /* # */) {
341
438
  const lowerPrefix = rawHref.slice(0, 11).toLowerCase();
342
439
  if (!lowerPrefix.startsWith('mailto:') && !lowerPrefix.startsWith('tel:') && !lowerPrefix.startsWith('javascript:')) {
@@ -361,8 +458,9 @@ function parseHtmlSax(html, finalUrl, origin) {
361
458
  }
362
459
  }
363
460
  }
364
- } else if (activeLink && name === 'a') {
365
- activeLinkDepth += 1;
461
+ } else if (name === 'a') {
462
+ if (activeLink) activeLinkDepth += 1;
463
+ if (a11yLinkStack.length > 0) a11yLinkStack[a11yLinkStack.length - 1].depth += 1;
366
464
  }
367
465
 
368
466
  // Heading detection (unlimited H1..H99 + ARIA role="heading" aria-level="1..99")
@@ -416,6 +514,10 @@ function parseHtmlSax(html, finalUrl, origin) {
416
514
  if (activeLink && activeLink.text.length < 130) {
417
515
  activeLink.text += text;
418
516
  }
517
+ if (a11yLinkStack.length > 0) {
518
+ const linkTop = a11yLinkStack[a11yLinkStack.length - 1];
519
+ if (linkTop.text.length < 130) linkTop.text += text;
520
+ }
419
521
  }
420
522
  },
421
523
 
@@ -431,6 +533,23 @@ function parseHtmlSax(html, finalUrl, origin) {
431
533
  currentJsonLd = '';
432
534
  }
433
535
 
536
+ if (name === 'a' && a11yLinkStack.length > 0) {
537
+ const linkTop = a11yLinkStack[a11yLinkStack.length - 1];
538
+ linkTop.depth -= 1;
539
+ if (linkTop.depth <= 0) {
540
+ a11yLinkStack.pop();
541
+ const cleanText = linkTop.text.replace(WS_COLLAPSE_REGEX, ' ').trim();
542
+ const hasName = Boolean(
543
+ cleanText ||
544
+ linkTop.ariaLabel ||
545
+ linkTop.ariaLabelledby ||
546
+ linkTop.title ||
547
+ linkTop.hasImgName
548
+ );
549
+ if (!linkTop.ariaHidden && !hasName) emptyAccessibleLinkCount += 1;
550
+ }
551
+ }
552
+
434
553
  if (activeLink && name === 'a') {
435
554
  activeLinkDepth -= 1;
436
555
  if (activeLinkDepth <= 0) {
@@ -535,6 +654,10 @@ function parseHtmlSax(html, finalUrl, origin) {
535
654
  siteIcon,
536
655
  siteLogo,
537
656
  genericLinkTextCount,
657
+ emptyAccessibleLinkCount,
658
+ iframeMissingTitleCount,
659
+ positiveTabindexCount,
660
+ hasMainLandmark,
538
661
  wordCount
539
662
  };
540
663
  }
@@ -580,6 +703,22 @@ export function analyzePage({
580
703
 
581
704
  const isHtml = Boolean(html) && (contentType.includes('text/html') || contentType.includes('xhtml') || contentType === '' || renderedWithJs);
582
705
 
706
+ // Enrich / normalize crawl failure reason once at analyze boundary
707
+ let resolvedError = error ? humanizeCrawlErrorMessage(error) : null;
708
+ if (!resolvedError) {
709
+ const ct = (contentType || '').toLowerCase();
710
+ const looksHtml = !ct || ct.includes('html') || ct.includes('xhtml') || renderedWithJs;
711
+ if (!looksHtml && !html) {
712
+ resolvedError = formatNonHtmlError(contentType);
713
+ } else if ((finalStatus === 401 || finalStatus === 403) && !html) {
714
+ resolvedError = formatHttpStatusError(finalStatus);
715
+ } else if (finalStatus === 0) {
716
+ resolvedError = 'Verbindungsfehler';
717
+ } else if (finalStatus >= 400 && !isHtml) {
718
+ resolvedError = formatHttpStatusError(finalStatus);
719
+ }
720
+ }
721
+
583
722
  let title = '';
584
723
  let metaDescription = '';
585
724
  let robots = parseRobotsDirectives([], headers['x-robots-tag'] || '');
@@ -614,6 +753,10 @@ export function analyzePage({
614
753
  let siteIcon = '';
615
754
  let siteLogo = '';
616
755
  let genericLinkTextCount = 0;
756
+ let emptyAccessibleLinkCount = 0;
757
+ let iframeMissingTitleCount = 0;
758
+ let positiveTabindexCount = 0;
759
+ let hasMainLandmark = false;
617
760
  let wordCount = 0;
618
761
 
619
762
  if (isHtml && html) {
@@ -650,6 +793,10 @@ export function analyzePage({
650
793
  siteIcon = parsed.siteIcon;
651
794
  siteLogo = parsed.siteLogo;
652
795
  genericLinkTextCount = parsed.genericLinkTextCount;
796
+ emptyAccessibleLinkCount = parsed.emptyAccessibleLinkCount;
797
+ iframeMissingTitleCount = parsed.iframeMissingTitleCount;
798
+ positiveTabindexCount = parsed.positiveTabindexCount;
799
+ hasMainLandmark = parsed.hasMainLandmark;
653
800
  wordCount = parsed.wordCount;
654
801
  }
655
802
 
@@ -669,7 +816,7 @@ export function analyzePage({
669
816
  initialStatus,
670
817
  finalStatus,
671
818
  status: finalStatus || initialStatus,
672
- error,
819
+ error: resolvedError,
673
820
  responseTimeMs,
674
821
  renderedWithJs,
675
822
  contentType,
@@ -719,6 +866,10 @@ export function analyzePage({
719
866
  siteIcon,
720
867
  siteLogo,
721
868
  genericLinkTextCount,
869
+ emptyAccessibleLinkCount,
870
+ iframeMissingTitleCount,
871
+ positiveTabindexCount,
872
+ hasMainLandmark,
722
873
  contentSizeBytes,
723
874
  wordCount,
724
875
  note: ''