New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

express-minify-html-terser

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

express-minify-html-terser - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

76

minifier.js

@@ -1,22 +0,24 @@

'use strict';
"use strict";
var objectMerge = require('lodash.merge'),
minify = require('html-minifier-terser').minify;
var objectMerge = require("lodash.merge"),
minify = require("html-minifier-terser").minify;
function minifyHTML(opts) {
var default_opts = {
override: false,
exception_url: false,
htmlMinifier: {
removeComments: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
var default_opts = {
override: true,
exception_url: false,
htmlMinifier: {
minifyCSS: true,
minifyJS: true,
removeComments: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
removeEmptyAttributes: true,
continueOnParseError: true
}
};
continueOnParseError: true,
},
};
if (!opts) {
opts = {};
if (!opts) {
opts = {};
}

@@ -27,3 +29,3 @@

if (opts.exception_url.constructor !== Array) {
opts.exception_url = [ opts.exception_url ];
opts.exception_url = [opts.exception_url];
}

@@ -34,3 +36,3 @@

opts.exception_url.every(function(exception){
opts.exception_url.every(function (exception) {
switch (true) {

@@ -53,24 +55,22 @@ case exception.constructor === RegExp:

var sendMinified = function (callback) {
// No callback specified, just minify and send to client.
if (typeof callback === 'undefined') {
return function (err, html) {
if (err) {
return next(err);
}
if (typeof callback === "undefined") {
return function (err, html) {
if (err) {
return next(err);
}
html = minify(html, opts.htmlMinifier);
res.send(html);
};
} else {
// Custom callback specified by user, use that one
return function (err, html) {
if (html) {
html = minify(html, opts.htmlMinifier);
res.send(html);
}
} else {
// Custom callback specified by user, use that one
return function (err, html) {
if (html) {
html = minify(html, opts.htmlMinifier);
}
callback(err, html);
}
}
callback(err, html);
};
}
};

@@ -83,5 +83,5 @@

if (opts.override && !skip) {
res.oldRender = res.render;
var render = res.render;
res.render = function (view, renderOpts, callback) {
this.oldRender(view, renderOpts, sendMinified(callback));
render.call(this, view, renderOpts, sendMinified(callback));
};

@@ -93,5 +93,5 @@ }

return (minifier);
return minifier;
}
module.exports = minifyHTML;
{
"name": "express-minify-html-terser",
"version": "1.0.0",
"version": "1.0.1",
"description": "Express middleware around HTML minifier",

@@ -5,0 +5,0 @@ "main": "minifier.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc