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/lib/crawler.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
2
|
import { EventEmitter } from 'node:events';
|
|
3
3
|
import { fetchWithRedirects } from './analyzer.js';
|
|
4
|
+
import { formatNetworkError, isTimeoutErrorMessage } from './crawl-error.js';
|
|
4
5
|
import { closeHttpPool, fastFetch } from './http-client.js';
|
|
5
6
|
import { JsRenderer } from './renderer.js';
|
|
6
7
|
import { ensureCrawlScores, scorePage, summarizeCrawlAudit } from './scorer.js';
|
|
@@ -103,12 +104,44 @@ export function buildScriptsSummary(pages = [], trackerRules = []) {
|
|
|
103
104
|
class CrawlManager {
|
|
104
105
|
constructor() {
|
|
105
106
|
this.activeCrawls = new Map(); // id -> { crawl, emitter, stopRequested, renderer, auth }
|
|
107
|
+
// In-flight link/redirect checks (survives completed crawls; polled by UI for progress bars)
|
|
108
|
+
this.checkJobs = new Map(); // `${type}:${crawlId}` -> { type, status, checked, total, phase, error, updatedAt }
|
|
106
109
|
}
|
|
107
110
|
|
|
108
111
|
getActive(id) {
|
|
109
112
|
return this.activeCrawls.get(id) || null;
|
|
110
113
|
}
|
|
111
114
|
|
|
115
|
+
#checkJobKey(crawlId, type) {
|
|
116
|
+
return `${type}:${crawlId}`;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
getCheckProgress(crawlId, type) {
|
|
120
|
+
const job = this.checkJobs.get(this.#checkJobKey(crawlId, type));
|
|
121
|
+
if (!job) return { status: 'idle', type, checked: 0, total: 0, phase: '', error: null };
|
|
122
|
+
return { ...job };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Public setter for early phases (e.g. sitemap load before runRedirectCheck). */
|
|
126
|
+
setCheckProgress(crawlId, type, patch) {
|
|
127
|
+
return this.#setCheckProgress(crawlId, type, patch);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
#setCheckProgress(crawlId, type, patch) {
|
|
131
|
+
const key = this.#checkJobKey(crawlId, type);
|
|
132
|
+
const prev = this.checkJobs.get(key) || {
|
|
133
|
+
type,
|
|
134
|
+
status: 'idle',
|
|
135
|
+
checked: 0,
|
|
136
|
+
total: 0,
|
|
137
|
+
phase: '',
|
|
138
|
+
error: null
|
|
139
|
+
};
|
|
140
|
+
const next = { ...prev, ...patch, type, updatedAt: Date.now() };
|
|
141
|
+
this.checkJobs.set(key, next);
|
|
142
|
+
return next;
|
|
143
|
+
}
|
|
144
|
+
|
|
112
145
|
async getCrawl(id) {
|
|
113
146
|
const active = this.activeCrawls.get(id);
|
|
114
147
|
if (active) {
|
|
@@ -529,7 +562,7 @@ class CrawlManager {
|
|
|
529
562
|
fetched.finalStatus === 429 ||
|
|
530
563
|
fetched.finalStatus === 503 ||
|
|
531
564
|
fetched.finalStatus === 502 ||
|
|
532
|
-
fetched.error
|
|
565
|
+
isTimeoutErrorMessage(fetched.error) ||
|
|
533
566
|
(fetched.finalStatus === 0 && fetched.error);
|
|
534
567
|
|
|
535
568
|
const processOne = async (targetUrl) => {
|
|
@@ -734,218 +767,296 @@ class CrawlManager {
|
|
|
734
767
|
const crawl = await this.getCrawl(crawlId);
|
|
735
768
|
if (!crawl) throw new Error('Crawl nicht gefunden.');
|
|
736
769
|
|
|
737
|
-
|
|
738
|
-
for (const p of crawl.pages || []) {
|
|
739
|
-
const addLinks = (list, type) => {
|
|
740
|
-
for (const l of list || []) {
|
|
741
|
-
if (scope !== 'all' && scope !== type) continue;
|
|
742
|
-
if (!linkMap.has(l.url)) {
|
|
743
|
-
linkMap.set(l.url, {
|
|
744
|
-
url: l.url,
|
|
745
|
-
type,
|
|
746
|
-
sources: new Set(),
|
|
747
|
-
sourceUrls: new Map(),
|
|
748
|
-
sampleText: l.text || ''
|
|
749
|
-
});
|
|
750
|
-
}
|
|
751
|
-
linkMap.get(key).sources.add(p.path);
|
|
752
|
-
if (l.fromSection) {
|
|
753
|
-
linkMap.get(key).sourceUrls.set(p.url, {
|
|
754
|
-
path: p.path,
|
|
755
|
-
section: l.fromSection,
|
|
756
|
-
sectionTag: l.sectionTag || ''
|
|
757
|
-
});
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
};
|
|
761
|
-
addLinks(p.internalLinks, 'internal');
|
|
762
|
-
addLinks(p.externalLinks, 'external');
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
const targets = [...linkMap.values()];
|
|
766
|
-
crawl.linkCheck = {
|
|
770
|
+
this.#setCheckProgress(crawlId, 'links', {
|
|
767
771
|
status: 'running',
|
|
768
|
-
scope,
|
|
769
|
-
checkedAt: new Date().toISOString(),
|
|
770
|
-
total: targets.length,
|
|
771
772
|
checked: 0,
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
773
|
+
total: 0,
|
|
774
|
+
phase: 'Sammle Links…',
|
|
775
|
+
error: null
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
try {
|
|
779
|
+
const linkMap = new Map();
|
|
780
|
+
for (const p of crawl.pages || []) {
|
|
781
|
+
const addLinks = (list, type) => {
|
|
782
|
+
for (const l of list || []) {
|
|
783
|
+
if (scope !== 'all' && scope !== type) continue;
|
|
784
|
+
if (!linkMap.has(l.url)) {
|
|
785
|
+
linkMap.set(l.url, {
|
|
786
|
+
url: l.url,
|
|
787
|
+
type,
|
|
788
|
+
sources: new Set(),
|
|
789
|
+
sourceUrls: new Map(),
|
|
790
|
+
sampleText: l.text || ''
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
const entry = linkMap.get(l.url);
|
|
794
|
+
entry.sources.add(p.path);
|
|
795
|
+
if (l.fromSection) {
|
|
796
|
+
entry.sourceUrls.set(p.url, {
|
|
797
|
+
path: p.path,
|
|
798
|
+
section: l.fromSection,
|
|
799
|
+
sectionTag: l.sectionTag || ''
|
|
800
|
+
});
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
addLinks(p.internalLinks, 'internal');
|
|
805
|
+
addLinks(p.externalLinks, 'external');
|
|
806
|
+
}
|
|
775
807
|
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
808
|
+
const targets = [...linkMap.values()];
|
|
809
|
+
crawl.linkCheck = {
|
|
810
|
+
status: 'running',
|
|
811
|
+
scope,
|
|
812
|
+
checkedAt: new Date().toISOString(),
|
|
813
|
+
total: targets.length,
|
|
814
|
+
checked: 0,
|
|
815
|
+
brokenCount: 0,
|
|
816
|
+
results: []
|
|
817
|
+
};
|
|
818
|
+
this.#setCheckProgress(crawlId, 'links', {
|
|
819
|
+
status: 'running',
|
|
820
|
+
checked: 0,
|
|
821
|
+
total: targets.length,
|
|
822
|
+
phase: targets.length ? 'Prüfe Links…' : 'Keine Links gefunden',
|
|
823
|
+
error: null
|
|
824
|
+
});
|
|
780
825
|
|
|
781
|
-
|
|
782
|
-
const
|
|
783
|
-
const
|
|
784
|
-
|
|
785
|
-
let status = 0;
|
|
786
|
-
let finalUrl = item.url;
|
|
787
|
-
let error = null;
|
|
826
|
+
const authHeaders = buildAuthHeaders(auth);
|
|
827
|
+
const plainHeaders = buildAuthHeaders(null);
|
|
828
|
+
const results = [];
|
|
829
|
+
let idx = 0;
|
|
788
830
|
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
res = await fetch(item.url, {
|
|
799
|
-
method: '
|
|
831
|
+
const checkOne = async (item) => {
|
|
832
|
+
const isInternal = item.type === 'internal';
|
|
833
|
+
const headers = isInternal ? authHeaders : plainHeaders;
|
|
834
|
+
const started = Date.now();
|
|
835
|
+
let status = 0;
|
|
836
|
+
let finalUrl = item.url;
|
|
837
|
+
let error = null;
|
|
838
|
+
|
|
839
|
+
try {
|
|
840
|
+
let res = await fetch(item.url, {
|
|
841
|
+
method: 'HEAD',
|
|
800
842
|
headers,
|
|
801
843
|
redirect: 'follow',
|
|
802
|
-
signal: AbortSignal.timeout(
|
|
844
|
+
signal: AbortSignal.timeout(10000)
|
|
803
845
|
});
|
|
846
|
+
if ([400, 403, 405, 406, 501].includes(res.status)) {
|
|
847
|
+
await res.body?.cancel().catch(() => {});
|
|
848
|
+
res = await fetch(item.url, {
|
|
849
|
+
method: 'GET',
|
|
850
|
+
headers,
|
|
851
|
+
redirect: 'follow',
|
|
852
|
+
signal: AbortSignal.timeout(12000)
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
status = res.status;
|
|
856
|
+
finalUrl = res.url || item.url;
|
|
857
|
+
await res.body?.cancel().catch(() => {});
|
|
858
|
+
} catch (err) {
|
|
859
|
+
error = formatNetworkError(err, { timeoutMs: 12000 }) || 'Netzwerkfehler';
|
|
804
860
|
}
|
|
805
|
-
status = res.status;
|
|
806
|
-
finalUrl = res.url || item.url;
|
|
807
|
-
await res.body?.cancel().catch(() => {});
|
|
808
|
-
} catch (err) {
|
|
809
|
-
error = err.name === 'TimeoutError' ? 'Timeout' : (err.message || 'Netzwerkfehler');
|
|
810
|
-
}
|
|
811
861
|
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
862
|
+
const broken = status === 0 || status >= 400;
|
|
863
|
+
results.push({
|
|
864
|
+
url: item.url,
|
|
865
|
+
finalUrl,
|
|
866
|
+
type: item.type,
|
|
867
|
+
status,
|
|
868
|
+
broken,
|
|
869
|
+
error,
|
|
870
|
+
responseTimeMs: Date.now() - started,
|
|
871
|
+
sampleText: item.sampleText,
|
|
872
|
+
sources: [...item.sources],
|
|
873
|
+
sourceDetails: [...item.sourceUrls.values()].map((s) => ({ path: s.path, url: s.url, section: s.section, sectionTag: s.sectionTag }))
|
|
874
|
+
});
|
|
875
|
+
crawl.linkCheck.checked = results.length;
|
|
876
|
+
this.#setCheckProgress(crawlId, 'links', {
|
|
877
|
+
status: 'running',
|
|
878
|
+
checked: results.length,
|
|
879
|
+
total: targets.length,
|
|
880
|
+
phase: 'Prüfe Links…'
|
|
881
|
+
});
|
|
882
|
+
};
|
|
827
883
|
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
884
|
+
const workers = Array.from({ length: Math.min(40, Math.max(1, targets.length)) }, async () => {
|
|
885
|
+
while (idx < targets.length) {
|
|
886
|
+
const current = targets[idx++];
|
|
887
|
+
if (current) await checkOne(current);
|
|
888
|
+
}
|
|
889
|
+
});
|
|
890
|
+
await Promise.all(workers);
|
|
835
891
|
|
|
836
|
-
|
|
892
|
+
results.sort((a, b) => Number(b.broken) - Number(a.broken) || b.status - a.status);
|
|
837
893
|
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
894
|
+
const brokenBySource = new Map();
|
|
895
|
+
for (const r of results) {
|
|
896
|
+
if (!r.broken) continue;
|
|
897
|
+
for (const srcPath of r.sources) {
|
|
898
|
+
brokenBySource.set(srcPath, (brokenBySource.get(srcPath) || 0) + 1);
|
|
899
|
+
}
|
|
843
900
|
}
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
};
|
|
901
|
+
for (const p of crawl.pages || []) {
|
|
902
|
+
p.brokenLinksCount = brokenBySource.get(p.path) || 0;
|
|
903
|
+
p.audit = scorePage(p);
|
|
904
|
+
}
|
|
905
|
+
crawl.auditSummary = summarizeCrawlAudit(crawl);
|
|
906
|
+
|
|
907
|
+
crawl.linkCheck = {
|
|
908
|
+
status: 'completed',
|
|
909
|
+
scope,
|
|
910
|
+
checkedAt: new Date().toISOString(),
|
|
911
|
+
total: targets.length,
|
|
912
|
+
checked: results.length,
|
|
913
|
+
brokenCount: results.filter((r) => r.broken).length,
|
|
914
|
+
results
|
|
915
|
+
};
|
|
860
916
|
|
|
861
|
-
|
|
862
|
-
|
|
917
|
+
await saveCrawl(crawl);
|
|
918
|
+
this.#setCheckProgress(crawlId, 'links', {
|
|
919
|
+
status: 'completed',
|
|
920
|
+
checked: results.length,
|
|
921
|
+
total: targets.length,
|
|
922
|
+
phase: 'Fertig',
|
|
923
|
+
error: null
|
|
924
|
+
});
|
|
925
|
+
return crawl.linkCheck;
|
|
926
|
+
} catch (err) {
|
|
927
|
+
this.#setCheckProgress(crawlId, 'links', {
|
|
928
|
+
status: 'error',
|
|
929
|
+
phase: 'Fehler',
|
|
930
|
+
error: err.message || 'Link-Check fehlgeschlagen'
|
|
931
|
+
});
|
|
932
|
+
throw err;
|
|
933
|
+
}
|
|
863
934
|
}
|
|
864
935
|
|
|
865
936
|
async runRedirectCheck(crawlId, { entries = [], auth = null } = {}) {
|
|
866
937
|
const crawl = await this.getCrawl(crawlId);
|
|
867
938
|
if (!crawl) throw new Error('Crawl nicht gefunden.');
|
|
868
939
|
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
940
|
+
this.#setCheckProgress(crawlId, 'redirects', {
|
|
941
|
+
status: 'running',
|
|
942
|
+
checked: 0,
|
|
943
|
+
total: 0,
|
|
944
|
+
phase: 'Bereite URLs vor…',
|
|
945
|
+
error: null
|
|
946
|
+
});
|
|
947
|
+
|
|
948
|
+
try {
|
|
949
|
+
const cleanEntries = entries
|
|
950
|
+
.map((e) => {
|
|
951
|
+
let oldUrl = String(e.oldUrl || '').trim();
|
|
952
|
+
let expectedUrl = String(e.expectedUrl || '').trim();
|
|
953
|
+
if (!oldUrl) return null;
|
|
954
|
+
if (oldUrl.startsWith('/')) {
|
|
955
|
+
oldUrl = `${crawl.origin}${oldUrl}`;
|
|
956
|
+
} else if (!/^https?:\/\//i.test(oldUrl)) {
|
|
957
|
+
oldUrl = `https://${oldUrl}`;
|
|
884
958
|
}
|
|
959
|
+
if (expectedUrl) {
|
|
960
|
+
if (expectedUrl.startsWith('/')) {
|
|
961
|
+
expectedUrl = `${crawl.origin}${expectedUrl}`;
|
|
962
|
+
} else if (!/^https?:\/\//i.test(expectedUrl)) {
|
|
963
|
+
expectedUrl = `https://${expectedUrl}`;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
return { oldUrl, expectedUrl: expectedUrl || null };
|
|
967
|
+
})
|
|
968
|
+
.filter(Boolean);
|
|
969
|
+
|
|
970
|
+
const results = new Array(cleanEntries.length);
|
|
971
|
+
let idx = 0;
|
|
972
|
+
let checkedCount = 0;
|
|
973
|
+
|
|
974
|
+
this.#setCheckProgress(crawlId, 'redirects', {
|
|
975
|
+
status: 'running',
|
|
976
|
+
checked: 0,
|
|
977
|
+
total: cleanEntries.length,
|
|
978
|
+
phase: cleanEntries.length ? 'Prüfe Weiterleitungen…' : 'Keine URLs',
|
|
979
|
+
error: null
|
|
980
|
+
});
|
|
981
|
+
|
|
982
|
+
const checkOne = async (entry, position) => {
|
|
983
|
+
const fetched = await fetchWithRedirects(entry.oldUrl, auth, 12000);
|
|
984
|
+
const hops = fetched.redirectChain.length;
|
|
985
|
+
const firstStatus = fetched.initialStatus;
|
|
986
|
+
const finalStatus = fetched.finalStatus;
|
|
987
|
+
const finalUrl = fetched.finalUrl;
|
|
988
|
+
|
|
989
|
+
let verdict = 'ok';
|
|
990
|
+
let verdictLabel = 'OK';
|
|
991
|
+
|
|
992
|
+
if (fetched.error || finalStatus === 0 || finalStatus >= 400) {
|
|
993
|
+
verdict = 'broken';
|
|
994
|
+
verdictLabel = hops > 0 ? `Redirect auf ${finalStatus || 'Fehler'}` : `${finalStatus || 'Fehler'} (Ohne Seite)`;
|
|
995
|
+
} else if (entry.expectedUrl && canonicalCompareKey(finalUrl) !== canonicalCompareKey(entry.expectedUrl)) {
|
|
996
|
+
verdict = 'wrong_target';
|
|
997
|
+
verdictLabel = 'Abweichendes Ziel';
|
|
998
|
+
} else if (hops > 1) {
|
|
999
|
+
verdict = 'chain';
|
|
1000
|
+
verdictLabel = `Redirect-Kette (${hops} Hops)`;
|
|
1001
|
+
} else if (hops === 1 && (firstStatus === 302 || firstStatus === 307)) {
|
|
1002
|
+
verdict = 'temp_redirect';
|
|
1003
|
+
verdictLabel = `Temporär (${firstStatus})`;
|
|
1004
|
+
} else if (hops === 1 && (firstStatus === 301 || firstStatus === 308)) {
|
|
1005
|
+
verdict = 'ok_redirect';
|
|
1006
|
+
verdictLabel = `${firstStatus} OK`;
|
|
1007
|
+
} else if (hops === 0 && finalStatus >= 200 && finalStatus < 300) {
|
|
1008
|
+
verdict = 'no_redirect';
|
|
1009
|
+
verdictLabel = '200 Direkt';
|
|
885
1010
|
}
|
|
886
|
-
return { oldUrl, expectedUrl: expectedUrl || null };
|
|
887
|
-
})
|
|
888
|
-
.filter(Boolean);
|
|
889
|
-
|
|
890
|
-
const results = new Array(cleanEntries.length);
|
|
891
|
-
let idx = 0;
|
|
892
|
-
|
|
893
|
-
const checkOne = async (entry, position) => {
|
|
894
|
-
const fetched = await fetchWithRedirects(entry.oldUrl, auth, 12000);
|
|
895
|
-
const hops = fetched.redirectChain.length;
|
|
896
|
-
const firstStatus = fetched.initialStatus;
|
|
897
|
-
const finalStatus = fetched.finalStatus;
|
|
898
|
-
const finalUrl = fetched.finalUrl;
|
|
899
|
-
|
|
900
|
-
let verdict = 'ok';
|
|
901
|
-
let verdictLabel = 'OK';
|
|
902
|
-
|
|
903
|
-
if (fetched.error || finalStatus === 0 || finalStatus >= 400) {
|
|
904
|
-
verdict = 'broken';
|
|
905
|
-
verdictLabel = hops > 0 ? `Redirect auf ${finalStatus || 'Fehler'}` : `${finalStatus || 'Fehler'} (Ohne Seite)`;
|
|
906
|
-
} else if (entry.expectedUrl && canonicalCompareKey(finalUrl) !== canonicalCompareKey(entry.expectedUrl)) {
|
|
907
|
-
verdict = 'wrong_target';
|
|
908
|
-
verdictLabel = 'Abweichendes Ziel';
|
|
909
|
-
} else if (hops > 1) {
|
|
910
|
-
verdict = 'chain';
|
|
911
|
-
verdictLabel = `Redirect-Kette (${hops} Hops)`;
|
|
912
|
-
} else if (hops === 1 && (firstStatus === 302 || firstStatus === 307)) {
|
|
913
|
-
verdict = 'temp_redirect';
|
|
914
|
-
verdictLabel = `Temporär (${firstStatus})`;
|
|
915
|
-
} else if (hops === 1 && (firstStatus === 301 || firstStatus === 308)) {
|
|
916
|
-
verdict = 'ok_redirect';
|
|
917
|
-
verdictLabel = `${firstStatus} OK`;
|
|
918
|
-
} else if (hops === 0 && finalStatus >= 200 && finalStatus < 300) {
|
|
919
|
-
verdict = 'no_redirect';
|
|
920
|
-
verdictLabel = '200 Direkt';
|
|
921
|
-
}
|
|
922
1011
|
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
1012
|
+
results[position] = {
|
|
1013
|
+
oldUrl: entry.oldUrl,
|
|
1014
|
+
expectedUrl: entry.expectedUrl,
|
|
1015
|
+
initialStatus: firstStatus,
|
|
1016
|
+
finalStatus,
|
|
1017
|
+
finalUrl,
|
|
1018
|
+
hops,
|
|
1019
|
+
redirectChain: fetched.redirectChain,
|
|
1020
|
+
verdict,
|
|
1021
|
+
verdictLabel,
|
|
1022
|
+
responseTimeMs: fetched.responseTimeMs,
|
|
1023
|
+
error: fetched.error
|
|
1024
|
+
};
|
|
1025
|
+
checkedCount += 1;
|
|
1026
|
+
this.#setCheckProgress(crawlId, 'redirects', {
|
|
1027
|
+
status: 'running',
|
|
1028
|
+
checked: checkedCount,
|
|
1029
|
+
total: cleanEntries.length,
|
|
1030
|
+
phase: 'Prüfe Weiterleitungen…'
|
|
1031
|
+
});
|
|
935
1032
|
};
|
|
936
|
-
};
|
|
937
1033
|
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
1034
|
+
const workers = Array.from({ length: Math.min(40, Math.max(1, cleanEntries.length)) }, async () => {
|
|
1035
|
+
while (idx < cleanEntries.length) {
|
|
1036
|
+
const i = idx++;
|
|
1037
|
+
if (cleanEntries[i]) await checkOne(cleanEntries[i], i);
|
|
1038
|
+
}
|
|
1039
|
+
});
|
|
1040
|
+
await Promise.all(workers);
|
|
945
1041
|
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
1042
|
+
crawl.redirectChecks = results;
|
|
1043
|
+
await saveCrawl(crawl);
|
|
1044
|
+
this.#setCheckProgress(crawlId, 'redirects', {
|
|
1045
|
+
status: 'completed',
|
|
1046
|
+
checked: cleanEntries.length,
|
|
1047
|
+
total: cleanEntries.length,
|
|
1048
|
+
phase: 'Fertig',
|
|
1049
|
+
error: null
|
|
1050
|
+
});
|
|
1051
|
+
return results;
|
|
1052
|
+
} catch (err) {
|
|
1053
|
+
this.#setCheckProgress(crawlId, 'redirects', {
|
|
1054
|
+
status: 'error',
|
|
1055
|
+
phase: 'Fehler',
|
|
1056
|
+
error: err.message || 'Redirect-Check fehlgeschlagen'
|
|
1057
|
+
});
|
|
1058
|
+
throw err;
|
|
1059
|
+
}
|
|
949
1060
|
}
|
|
950
1061
|
|
|
951
1062
|
async shutdown() {
|