single-file-core 1.3.25 → 1.3.27
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 +2 -0
- package/core/util.js +3 -0
- package/package.json +1 -1
- package/vendor/css-minifier.js +5 -2
package/core/index.js
CHANGED
|
@@ -588,12 +588,14 @@ class Processor {
|
|
|
588
588
|
this.stats.add("discarded", "HTML bytes", size - contentSize);
|
|
589
589
|
}
|
|
590
590
|
const filename = await util.formatFilename(content, this.doc, this.options);
|
|
591
|
+
const mimeType = util.getMimeType(this.options);
|
|
591
592
|
const matchTitle = this.baseURI.match(/([^/]*)\/?(\.html?.*)$/) || this.baseURI.match(/\/\/([^/]*)\/?$/);
|
|
592
593
|
const additionalData = this.processorHelper.getAdditionalPageData(this.doc, content, this.resources);
|
|
593
594
|
const pageData = Object.assign({
|
|
594
595
|
stats: this.stats.data,
|
|
595
596
|
title: this.options.title || (this.baseURI && matchTitle ? matchTitle[1] : url.hostname ? url.hostname : ""),
|
|
596
597
|
filename,
|
|
598
|
+
mimeType,
|
|
597
599
|
content
|
|
598
600
|
}, additionalData);
|
|
599
601
|
if (this.options.addProof) {
|
package/core/util.js
CHANGED
|
@@ -154,6 +154,9 @@ function getInstance(utilOptions) {
|
|
|
154
154
|
formatFilename(content, doc, options) {
|
|
155
155
|
return modules.templateFormatter.formatFilename(content, doc, options);
|
|
156
156
|
},
|
|
157
|
+
getMimeType(options) {
|
|
158
|
+
return !options.compressContent || options.selfExtractingArchive ? "text/html" : "application/zip";
|
|
159
|
+
},
|
|
157
160
|
async evalTemplate(template, options, content, doc, dontReplaceSlash) {
|
|
158
161
|
return modules.templateFormatter.evalTemplate(template, options, content, doc, dontReplaceSlash);
|
|
159
162
|
},
|
package/package.json
CHANGED
package/vendor/css-minifier.js
CHANGED
|
@@ -370,7 +370,9 @@ function collectComments(content, comments) {
|
|
|
370
370
|
const REGEXP_PRESERVE_STRING1 = /"([^\\"])*"/g;
|
|
371
371
|
const REGEXP_PRESERVE_STRING1_BIS = /"(\\.)*"/g;
|
|
372
372
|
const REGEXP_PRESERVE_STRING1_TER = /"(\\)*"/g;
|
|
373
|
-
const REGEXP_PRESERVE_STRING2 = /'([^\\']
|
|
373
|
+
const REGEXP_PRESERVE_STRING2 = /'([^\\'])*'/g;
|
|
374
|
+
const REGEXP_PRESERVE_STRING2_BIS = /'(\\.)*'/g;
|
|
375
|
+
const REGEXP_PRESERVE_STRING2_TER = /'(\\)*'/g;
|
|
374
376
|
const REGEXP_MINIFY_ALPHA = /progid:DXImageTransform.Microsoft.Alpha\(Opacity=/gi;
|
|
375
377
|
const REGEXP_PRESERVE_TOKEN1 = /\r\n/g;
|
|
376
378
|
const REGEXP_PRESERVE_TOKEN2 = /[\r\n]/g;
|
|
@@ -445,11 +447,12 @@ function processString(content = "", options = defaultOptions) {
|
|
|
445
447
|
content = extractDataUrls(content, preservedTokens);
|
|
446
448
|
content = collectComments(content, comments);
|
|
447
449
|
|
|
448
|
-
// preserve strings so their content doesn't get accidentally minified
|
|
449
450
|
preserveString(REGEXP_PRESERVE_STRING1);
|
|
450
451
|
preserveString(REGEXP_PRESERVE_STRING1_BIS);
|
|
451
452
|
preserveString(REGEXP_PRESERVE_STRING1_TER);
|
|
452
453
|
preserveString(REGEXP_PRESERVE_STRING2);
|
|
454
|
+
preserveString(REGEXP_PRESERVE_STRING2_BIS);
|
|
455
|
+
preserveString(REGEXP_PRESERVE_STRING2_TER);
|
|
453
456
|
|
|
454
457
|
function preserveString(pattern) {
|
|
455
458
|
content = content.replace(pattern, token => {
|