]> git.ardis.lu - envpass/commitdiff
Make tag deletion more robust for future template changes
authorArdis Lu <ardisglu@gmail.com>
Wed, 23 Sep 2026 06:17:43 +0000 (23:17 -0700)
committerArdis Lu <ardisglu@gmail.com>
Wed, 23 Sep 2026 06:17:43 +0000 (23:17 -0700)
The new regex will match all `<script>` or `<style>` tags in the file, regardless of attributes (e.g., SRI) or if there are multiple instances of the tag in the file.

test/getPrf.test.js

index 10423f92170119584c6eb8b737b3888272686dbc..1d68863d3767cc890707838de47bb391d2d3b0d1 100644 (file)
@@ -57,12 +57,12 @@ function makePostRequest(url, options = {}) {
 suite('getPrf.js (server)', () => {
   test('validates <style> tag is present in HTML template', async (t) => {
     const html = await getHTMLFromFile();
-    const modified = html.replaceAll('<style>', '');
+    const modified = html.replaceAll(/<style[^>]*>[\s\S]*?<\/style>/ig, '');
     await rejects(setupServer(t, { getHTML: () => modified }), { message: 'Could not find <style> tag in getPrf.html file.' });
   });
   test('validates <script> tag is present in HTML template', async (t) => {
     const html = await getHTMLFromFile();
-    const modified = html.replaceAll('<script type="module">', '');
+    const modified = html.replaceAll(/<script[^>]*>[\s\S]*?<\/script>/ig, '');
     await rejects(setupServer(t, { getHTML: () => modified }), { message: 'Could not find <script> tag in getPrf.html file.' });
   });
   test('valid GET works', async (t) => {
This page took 0.036635 seconds and 4 git commands to generate.