single-file-core 1.5.13 → 1.5.14

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/core/index.js CHANGED
@@ -1535,7 +1535,7 @@ class Processor {
1535
1535
  publisher: publisherElement && publisherElement.content ? publisherElement.content.trim() : "",
1536
1536
  heading: headingElement && headingElement.textContent ? headingElement.textContent.trim() : ""
1537
1537
  };
1538
- this.options.infobarContent = await util.evalTemplate(this.options.infobarTemplate, this.options, null, this.doc, true);
1538
+ this.options.infobarContent = await util.evalTemplate(this.options.infobarTemplate, this.options, null, this.doc, { dontReplaceSlash: true });
1539
1539
  }
1540
1540
  }
1541
1541
 
package/core/util.js CHANGED
@@ -166,8 +166,8 @@ function getInstance(utilOptions) {
166
166
  getMimeType(options) {
167
167
  return !options.compressContent || options.selfExtractingArchive ? "text/html" : "application/zip";
168
168
  },
169
- async evalTemplate(template, options, content, doc, dontReplaceSlash) {
170
- return modules.templateFormatter.evalTemplate(template, options, content, doc, dontReplaceSlash);
169
+ async evalTemplate(template, options, content, doc, context) {
170
+ return modules.templateFormatter.evalTemplate(template, options, content, doc, context);
171
171
  },
172
172
  minifyHTML(doc, options) {
173
173
  return modules.htmlMinifier.process(doc, options);
@@ -16899,7 +16899,9 @@ async function formatFilename(content, doc, options) {
16899
16899
  return filename.trim();
16900
16900
  }
16901
16901
 
16902
- async function evalTemplate(template = "", options, content, doc, dontReplaceSlash) {
16902
+ async function evalTemplate(template = "", options, content, doc, context = {}) {
16903
+ const { dontReplaceSlash } = context;
16904
+ context.currentDate = new Date();
16903
16905
  const url = new URL(options.saveUrl);
16904
16906
  const urlHref = decode(url.href);
16905
16907
  const params = Array.from(new URLSearchParams(url.search));
@@ -17018,11 +17020,11 @@ async function evalTemplate(template = "", options, content, doc, dontReplaceSla
17018
17020
  "decode-uri": value => { try { return decodeURI(value); } catch (error) { return value; } },
17019
17021
  "encode-uri-component": value => { try { return encodeURIComponent(value); } catch (error) { return value; } },
17020
17022
  "decode-uri-component": value => { try { return decodeURIComponent(value); } catch (error) { return value; } },
17021
- "date-locale": locales => new Date().toLocaleDateString(locales),
17022
- "time-locale": locales => new Date().toLocaleTimeString(locales),
17023
- "datetime-locale": locales => new Date().toLocaleString(locales),
17023
+ "date-locale": locales => context.currentDate.toLocaleDateString(locales),
17024
+ "time-locale": locales => context.currentDate.toLocaleTimeString(locales),
17025
+ "datetime-locale": locales => context.currentDate.toLocaleString(locales),
17024
17026
  "datetime-custom": (locale, year, month, day, weekday, hour, minute, second, hour12, timeZone, fractionalSecondDigits, timeZoneName, dayPeriod, era, localeMatcher) => {
17025
- const date = new Date();
17027
+ const date = context.currentDate;
17026
17028
  const options = {};
17027
17029
  setOption(options, "year", year);
17028
17030
  setOption(options, "month", month);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-core",
3
- "version": "1.5.13",
3
+ "version": "1.5.14",
4
4
  "description": "SingleFile Core",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",