fix: Eventseite ohne JavaScript-Syntaxfehler
This commit is contained in:
1 parent
a235112f4b
commit
29f36009f0
2 files changed
+20
-1
No files matched your search
@@ -19,7 +19,7 @@
|
|||||||
</script>
|
</script>
|
||||||
<!-- Google Tag Manager -->
|
<!-- Google Tag Manager -->
|
||||||
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
||||||
new Date().getTime(),event:'gtm.js'};var f=d.getElementsByTagName(s)[0],
|
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
||||||
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
||||||
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
||||||
})(window,document,'script','dataLayer','GTM-T6CVBLPR');</script>
|
})(window,document,'script','dataLayer','GTM-T6CVBLPR');</script>
|
||||||
|
|||||||
@@ -293,6 +293,25 @@ if (wants('links')) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (wants('syntax')) {
|
||||||
|
check('alle ausführbaren Inline-Skripte der Top-Level-Seiten sind syntaktisch gültig', () => {
|
||||||
|
const files = readdirSync(PUBLIC).filter((file) => file.endsWith('.html')).sort();
|
||||||
|
for (const file of files) {
|
||||||
|
const html = pageHtml(file);
|
||||||
|
const scripts = Array.from(
|
||||||
|
html.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi),
|
||||||
|
(match) => ({ attributes: match[1], source: match[2] })
|
||||||
|
);
|
||||||
|
for (const [index, script] of scripts.entries()) {
|
||||||
|
if (/\bsrc\s*=/i.test(script.attributes) || /\btype\s*=\s*["']application\/ld\+json["']/i.test(script.attributes)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
new vm.Script(script.source, { filename: `${file} inline script ${index + 1}` });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (failures.length) {
|
if (failures.length) {
|
||||||
console.error(`\n${failures.length} Prüfung(en) fehlgeschlagen.`);
|
console.error(`\n${failures.length} Prüfung(en) fehlgeschlagen.`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|||||||
Reference in new issue
Block a user