]> git.ardis.lu - envpass/commitdiff
Do not hardcode local file name in error
authorArdis Lu <ardisglu@gmail.com>
Thu, 24 Sep 2026 06:09:48 +0000 (23:09 -0700)
committerArdis Lu <ardisglu@gmail.com>
Thu, 24 Sep 2026 06:09:48 +0000 (23:09 -0700)
Since `getHTML` is now a dependency injection, this file name may not be the same every time so this reference should not be hardcoded.

src/getPrf.js
test/getPrf.test.js

index cefd1a5bfb571e71046d894cd49cbaf206923e37..49a199d0a5bd66e6e7ae4307e5e1d781128d0809 100644 (file)
@@ -76,10 +76,10 @@ export async function getPrf(options = {}) {
   const style = html.match(/<style.*>([\s\S]*)<\/style>/i)?.[1];
   const script = html.match(/<script.*>([\s\S]*)<\/script>/i)?.[1];
   if (style === undefined) {
-    throw new Error('Could not find <style> tag in getPrf.html file.');
+    throw new Error('Could not find <style> tag in HTML template file.');
   }
   if (script === undefined) {
-    throw new Error('Could not find <script> tag in getPrf.html file.');
+    throw new Error('Could not find <script> tag in HTML template file.');
   }
   const styleHash = new Uint8Array(await crypto.subtle.digest('SHA-512', encoder.encode(style))).toBase64();
   const scriptHash = new Uint8Array(await crypto.subtle.digest('SHA-512', encoder.encode(script))).toBase64();
index 1d68863d3767cc890707838de47bb391d2d3b0d1..0ae306e449937b640d3cddbcfd119eee15258ab7 100644 (file)
@@ -58,12 +58,12 @@ suite('getPrf.js (server)', () => {
   test('validates <style> tag is present in HTML template', async (t) => {
     const html = await getHTMLFromFile();
     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.' });
+    await rejects(setupServer(t, { getHTML: () => modified }), { message: 'Could not find <style> tag in HTML template file.' });
   });
   test('validates <script> tag is present in HTML template', async (t) => {
     const html = await getHTMLFromFile();
     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.' });
+    await rejects(setupServer(t, { getHTML: () => modified }), { message: 'Could not find <script> tag in HTML template file.' });
   });
   test('valid GET works', async (t) => {
     const { url } = await setupServer(t);
This page took 0.03651 seconds and 4 git commands to generate.