sitecheckultra 2.0.3 → 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 +21 -6
- package/bin/sitecheckultra.js +65 -12
- package/lib/analyzer.js +162 -11
- package/lib/crawl-error.js +171 -0
- package/lib/crawler.js +297 -186
- package/lib/exporter.js +126 -110
- package/lib/page-preview.js +311 -0
- package/lib/scorer.js +50 -17
- package/package.json +7 -7
- package/public/app.js +490 -58
- package/public/index.html +27 -9
- package/public/styles.css +138 -1
- package/server.js +66 -2
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
|
-

|
|
8
8
|

|
|
9
9
|

|
|
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-
|
|
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/
|
|
157
|
-
- **Issues**: https://github.com/
|
|
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
|
---
|
package/bin/sitecheckultra.js
CHANGED
|
@@ -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,27 +150,36 @@ function checkForUpdates() {
|
|
|
106
150
|
const latest = JSON.parse(data);
|
|
107
151
|
const current = currentVersion();
|
|
108
152
|
|
|
109
|
-
|
|
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
|
-
|
|
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
172
|
// Auto-Update bei JEDEM Start (npx ODER globale Installation),
|
|
121
|
-
// außer SCU_NO_UPDATE=1
|
|
122
|
-
//
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
+
);
|
|
130
183
|
} else {
|
|
131
184
|
log(`ℹ Neue Version gefunden – update automatisch auf ${latest.version}…`, colors.cyan);
|
|
132
185
|
try {
|
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:
|
|
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
|
|
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
|
-
|
|
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:
|
|
404
|
+
imagesMissingAlt.push({ src: imgSrc, reason: 'missing' });
|
|
323
405
|
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
|
|
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 (
|
|
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: ''
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalizes crawl/network failures into concrete German UI messages.
|
|
3
|
+
* Used by analyzer/crawler at the boundary where errors are set; UI can also
|
|
4
|
+
* re-humanize legacy English undici strings from older crawl JSON.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const HTTP_REASON_PHRASES = {
|
|
8
|
+
400: 'Bad Request',
|
|
9
|
+
401: 'Unauthorized',
|
|
10
|
+
403: 'Forbidden',
|
|
11
|
+
404: 'Not Found',
|
|
12
|
+
405: 'Method Not Allowed',
|
|
13
|
+
407: 'Proxy Authentication Required',
|
|
14
|
+
408: 'Request Timeout',
|
|
15
|
+
410: 'Gone',
|
|
16
|
+
429: 'Too Many Requests',
|
|
17
|
+
500: 'Internal Server Error',
|
|
18
|
+
502: 'Bad Gateway',
|
|
19
|
+
503: 'Service Unavailable',
|
|
20
|
+
504: 'Gateway Timeout'
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** True for timeout messages we emit (and legacy "Timeout"). */
|
|
24
|
+
export function isTimeoutErrorMessage(msg) {
|
|
25
|
+
return typeof msg === 'string' && /^Timeout\b/i.test(msg.trim());
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function formatHttpStatusError(status) {
|
|
29
|
+
const code = Number(status) || 0;
|
|
30
|
+
if (!code) return 'HTTP-Fehler';
|
|
31
|
+
const phrase = HTTP_REASON_PHRASES[code];
|
|
32
|
+
return phrase ? `HTTP ${code} ${phrase}` : `HTTP ${code}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function formatNonHtmlError(contentType) {
|
|
36
|
+
const ct = (contentType || '').trim() || 'unbekannt';
|
|
37
|
+
return `Kein HTML (content-type: ${ct})`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function formatRobotsBlockedError(rule) {
|
|
41
|
+
if (rule) return `Durch robots.txt blockiert: Disallow ${rule}`;
|
|
42
|
+
return 'Durch robots.txt blockiert';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function formatRedirectLoopError(hops = 0) {
|
|
46
|
+
if (hops > 0) return `Zu viele Redirects (${hops}+)`;
|
|
47
|
+
return 'Zu viele Redirects';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Map Node/undici/Abort errors (or raw strings) to a German reason.
|
|
52
|
+
* @param {Error|string|null|undefined} err
|
|
53
|
+
* @param {{ timeoutMs?: number }} [opts]
|
|
54
|
+
*/
|
|
55
|
+
export function formatNetworkError(err, opts = {}) {
|
|
56
|
+
if (err == null || err === '') return null;
|
|
57
|
+
|
|
58
|
+
const name = typeof err === 'object' ? (err.name || '') : '';
|
|
59
|
+
const code = typeof err === 'object'
|
|
60
|
+
? (err.code || err.cause?.code || err.cause?.cause?.code || '')
|
|
61
|
+
: '';
|
|
62
|
+
const raw = typeof err === 'string'
|
|
63
|
+
? err
|
|
64
|
+
: String(err.message || err.cause?.message || 'Netzwerkfehler');
|
|
65
|
+
|
|
66
|
+
if (name === 'TimeoutError' || name === 'AbortError' || isTimeoutErrorMessage(raw)) {
|
|
67
|
+
const sec = opts.timeoutMs ? Math.max(1, Math.round(opts.timeoutMs / 1000)) : null;
|
|
68
|
+
return sec ? `Timeout nach ${sec}s` : 'Timeout';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return humanizeCrawlErrorMessage(raw, { code });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Re-humanize a stored error string (new DE messages pass through; EN/codes map to DE).
|
|
76
|
+
* @param {string|null|undefined} raw
|
|
77
|
+
* @param {{ code?: string, timeoutMs?: number, contentType?: string, robotsDisallowRule?: string }} [ctx]
|
|
78
|
+
*/
|
|
79
|
+
export function humanizeCrawlErrorMessage(raw, ctx = {}) {
|
|
80
|
+
if (raw == null || raw === '') return null;
|
|
81
|
+
const msg = String(raw).trim();
|
|
82
|
+
if (!msg) return null;
|
|
83
|
+
|
|
84
|
+
// Already German / already formatted — keep concrete messages
|
|
85
|
+
if (/^(Timeout nach \d+s|DNS nicht auflösbar|SSL-Zertifikat ungültig|Verbindung abgelehnt|Zu viele Redirects|Kein HTML|Durch robots\.txt|HTTP \d{3}\b)/i.test(msg)) {
|
|
86
|
+
return msg;
|
|
87
|
+
}
|
|
88
|
+
if (msg === 'Timeout' || /^The operation was aborted/i.test(msg) || /^This operation was aborted/i.test(msg)) {
|
|
89
|
+
const sec = ctx.timeoutMs ? Math.max(1, Math.round(ctx.timeoutMs / 1000)) : null;
|
|
90
|
+
return sec ? `Timeout nach ${sec}s` : 'Timeout';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const blob = `${ctx.code || ''} ${msg}`;
|
|
94
|
+
|
|
95
|
+
if (/ENOTFOUND|getaddrinfo|ERR_NAME_NOT_RESOLVED|DNS/i.test(blob)) {
|
|
96
|
+
return 'DNS nicht auflösbar';
|
|
97
|
+
}
|
|
98
|
+
if (/ECONNREFUSED|ERR_CONNECTION_REFUSED/i.test(blob)) {
|
|
99
|
+
return 'Verbindung abgelehnt';
|
|
100
|
+
}
|
|
101
|
+
if (/ECONNRESET|ERR_CONNECTION_RESET|socket hang up/i.test(blob)) {
|
|
102
|
+
return 'Verbindung zurückgesetzt';
|
|
103
|
+
}
|
|
104
|
+
if (/ETIMEDOUT|ESOCKETTIMEDOUT|ERR_CONNECTION_TIMED_OUT|Connect Timeout/i.test(blob)) {
|
|
105
|
+
const sec = ctx.timeoutMs ? Math.max(1, Math.round(ctx.timeoutMs / 1000)) : null;
|
|
106
|
+
return sec ? `Timeout nach ${sec}s` : 'Verbindungs-Timeout';
|
|
107
|
+
}
|
|
108
|
+
if (/ENETUNREACH|EHOSTUNREACH|ERR_ADDRESS_UNREACHABLE/i.test(blob)) {
|
|
109
|
+
return 'Host nicht erreichbar';
|
|
110
|
+
}
|
|
111
|
+
if (/CERT|SSL|TLS|UNABLE_TO_VERIFY|ERR_TLS|ERR_SSL|certificate/i.test(blob)) {
|
|
112
|
+
return 'SSL-Zertifikat ungültig';
|
|
113
|
+
}
|
|
114
|
+
if (/redirect|ERR_TOO_MANY_REDIRECTS/i.test(blob) && /many|zu viele|loop/i.test(blob)) {
|
|
115
|
+
return 'Zu viele Redirects';
|
|
116
|
+
}
|
|
117
|
+
if (/EAI_AGAIN/i.test(blob)) {
|
|
118
|
+
return 'DNS vorübergehend nicht verfügbar';
|
|
119
|
+
}
|
|
120
|
+
if (/EPROTO|protocol/i.test(blob) && /SSL|TLS|HTTPS/i.test(blob)) {
|
|
121
|
+
return 'SSL/TLS-Protokollfehler';
|
|
122
|
+
}
|
|
123
|
+
if (/fetch failed/i.test(msg) && ctx.code) {
|
|
124
|
+
return humanizeCrawlErrorMessage(ctx.code, ctx) || 'Netzwerkfehler';
|
|
125
|
+
}
|
|
126
|
+
if (/^Netzwerkfehler$/i.test(msg) || /^network error$/i.test(msg) || /^fetch failed$/i.test(msg)) {
|
|
127
|
+
return 'Netzwerkfehler';
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Strip noisy undici prefixes but keep short technical detail if unknown
|
|
131
|
+
const cleaned = msg
|
|
132
|
+
.replace(/^Error:\s*/i, '')
|
|
133
|
+
.replace(/^fetch failed:\s*/i, '')
|
|
134
|
+
.trim();
|
|
135
|
+
if (cleaned.length > 120) return `${cleaned.slice(0, 117)}…`;
|
|
136
|
+
return cleaned || 'Netzwerkfehler';
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Best human-readable crawl-failure reason for a page object (UI + exports).
|
|
141
|
+
* Returns null when the page was successfully fetched as HTML.
|
|
142
|
+
*/
|
|
143
|
+
export function describePageCrawlFailure(page) {
|
|
144
|
+
if (!page) return null;
|
|
145
|
+
|
|
146
|
+
if (page.error) {
|
|
147
|
+
return humanizeCrawlErrorMessage(page.error, {
|
|
148
|
+
contentType: page.contentType,
|
|
149
|
+
robotsDisallowRule: page.robotsDisallowRule
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const status = Number(page.status || page.finalStatus || 0);
|
|
154
|
+
if (status === 0) return 'Verbindungsfehler';
|
|
155
|
+
|
|
156
|
+
const ct = (page.contentType || '').toLowerCase();
|
|
157
|
+
const hasHtmlHint = !ct || ct.includes('html') || ct.includes('xhtml');
|
|
158
|
+
if (!hasHtmlHint && !(page.title || page.h1Text || (page.headings || []).length)) {
|
|
159
|
+
return formatNonHtmlError(page.contentType);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (status === 401 || status === 403) {
|
|
163
|
+
return formatHttpStatusError(status);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (page.blockedByRobotsTxt) {
|
|
167
|
+
return formatRobotsBlockedError(page.robotsDisallowRule);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return null;
|
|
171
|
+
}
|