Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

minimize

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minimize - npm Package Compare versions

Comparing version 0.7.4 to 0.7.5

29

lib/helpers.js

@@ -10,11 +10,2 @@ 'use strict';

//
// Some predefined elements and regular expressions.
//
var conditional = /\[if.+IE[\s\d]*\]>.+<\!\[endif\]/g
, ssi = /^\W*\#.*/g
, retain = /data|itemscope/
, cdataStart = /\/*<!\[CDATA\[/g
, cdataEnd = /\/*\]\]>/g;
//
// Predefined parsing options.

@@ -116,3 +107,3 @@ //

//
if (!self.config.empty && !retain.test(key) && !bool && !value) return result;
if (!self.config.empty && !/data|itemscope/.test(key) && !bool && !value) return result;
//

@@ -214,3 +205,3 @@ // Boolean attributes should be added sparse.

if (!this.config.cdata && ancestors && this.isJS(this.ancestor[ancestors - 1])) {
content = content.replace(cdataStart, '').replace(cdataEnd, '');
content = content.replace(/\/*<!\[CDATA\[/g, '').replace(/\/*\]\]>/g, '');
}

@@ -229,7 +220,8 @@

Helpers.prototype.comment = function comment(element) {
if (this.config.conditionals && conditional.test(element.data)) {
if (this.config.conditionals && /\[if.+IE[\s\d]*\]>.+<\!\[endif\]/g.test(element.data)) {
return '<!--' + element.data + '-->';
}
if(this.config.ssi && ssi.test(element.data)) {
return '<!--' + element.data + '-->';
if(this.config.ssi && /^\W*\#.*/g.test(element.data)) {
return '<!--' + element.data + '-->';
}

@@ -258,13 +250,4 @@

//
// Expose some additional members while testing.
//
if (process.env.NODE_ENV === 'test') {
Helpers.prototype.retain = retain;
Helpers.prototype.cdataStart = cdataStart;
Helpers.prototype.cdataEnd = cdataEnd;
}
//
// Create public proxies.
//
module.exports = Helpers;
{
"name": "minimize",
"version": "0.7.4",
"version": "0.7.5",
"description": "Minimize HTML",

@@ -5,0 +5,0 @@ "main": "./lib/minimize",

{
"content": "<div class=\"slide nodejs\">\n <h3>100% Node.js</h3>\n <p>\n We are Node.js experts and the first hosting platform to build\n our full stack in node. We understand your node application\n better than anyone.\n </p>\n </div>\n\n ",
"comment": "<!-- some HTML comment --><!--#include virtual=\"/header.html\" -->\n <div class=\"slide nodejs\">\n <h3>100% Node.js</h3>\n <p>\n We are Node.js experts and the first hosting platform to build\n our full stack in node. We understand your node application\n better than anyone.\n </p>\n </div>\n\n ",
"ssi": "<!--#include virtual=\"/header.html\" -->\n <div class=\"slide nodejs\">\n <h3>100% Node.js</h3>\n <p>\n We are Node.js experts and the first hosting platform to build\n our full stack in node. We understand your node application\n better than anyone.\n </p>\n </div>\n\n ",
"ssimulti": "<!--#include virtual=\"/head.html\" --><!--#include virtual=\"/header.html\" -->\n <div class=\"slide nodejs\">\n <h3>100% Node.js</h3>\n <p>\n We are Node.js experts and the first hosting platform to build\n our full stack in node. We understand your node application\n better than anyone.\n </p>\n </div>\n\n ",
"ie": "<!--[if IE 6]>Special instructions for IE 6 here<![endif]-->\n <div class=\"slide nodejs\">\n <h3>100% Node.js</h3>\n </div>",
"iemulti": "<!--[if IE 10]>Special instructions for IE 10 here<![endif]--><!--[if IE 6]>Special instructions for IE 6 here<![endif]-->\n <div class=\"slide nodejs\">\n <h3>100% Node.js</h3>\n </div>",
"interpunction": "<h3>Become a partner</h3>\n <p>\n Interested in being part of the solution?\n <a href=\"/company/contact\">Contact Nodejitsu to discuss</a>.\n </p>",

@@ -6,0 +9,0 @@ "code": "<code class=\"copy\">\n<span>var http = require('http');\nhttp.createServer(function (req, res) {\n res.writeHead(200, {'Content-Type': 'text/plain'});\n res.end('hello, i know nodejitsu');\n})listen(8080);</span><a href=\"#\"><s class=\"ss-layers\" role=\"presentation\"></s> copy</a></code>",

@@ -14,3 +14,3 @@ /*global beforeEach, afterEach*/

chai.use(sinonChai);
chai.Assertion.includeStack = true;
chai.config.includeStack = true;

@@ -59,7 +59,2 @@ describe('Helpers', function () {

it('which has a regular expression named retain', function () {
expect(helpers).to.have.property('retain');
expect(helpers.retain).to.be.a('regexp');
});
it('which has an named redundant', function () {

@@ -75,9 +70,2 @@ expect(list).to.have.property('redundant');

it('which has regular expressions for cdata', function () {
expect(helpers).to.have.property('cdataStart');
expect(helpers).to.have.property('cdataEnd');
expect(helpers.cdataStart).to.be.a('regexp');
expect(helpers.cdataEnd).to.be.a('regexp');
});
it('which has an inline element reference', function () {

@@ -448,30 +436,2 @@ expect(list).to.have.property('inline');

describe('regular expression retain', function () {
it('is a valid regular expression', function () {
function regexp () { return new RegExp(helpers.retain); }
expect(regexp).to.not.throw(Error);
});
it('matches data and itemscope', function () {
expect(helpers.retain.test('data')).to.be.true;
expect(helpers.retain.test('itemscope')).to.be.true;
});
});
describe('regular expression cdata', function () {
it('is a valid regular expression', function () {
function regexp () {
new RegExp(helpers.cdataStart);
new RegExp(helpers.cdataEnd);
}
expect(regexp).to.not.throw(Error);
});
it('matches closing and ending parts of CDATA', function () {
expect(helpers.cdataStart.test('//<![CDATA[')).to.be.true;
expect(helpers.cdataEnd.test('//]]>')).to.be.true;
});
});
describe('has options', function () {

@@ -489,2 +449,2 @@ it('which are all false by default', function () {

});
});
});

@@ -12,3 +12,3 @@ 'use strict';

chai.use(sinonChai);
chai.Assertion.includeStack = true;
chai.config.includeStack = true;

@@ -88,3 +88,3 @@ describe('Minimize', function () {

var commentable = new Minimize({ ssi: true });
commentable.parse(html.comment, function (error, result) {
commentable.parse(html.ssi, function (error, result) {
expect(result).to.equal('<!--#include virtual=\"/header.html\" --><div class=\"slide nodejs\"><h3>100% Node.js</h3><p>We are Node.js experts and the first hosting platform to build our full stack in node. We understand your node application better than anyone.</p></div>');

@@ -95,3 +95,11 @@ done();

it('should be configurable to retain conditional internet explorer comments', function (done) {
it('should be configurable to retain multiple server side includes', function (done) {
var commentable = new Minimize({ ssi: true });
commentable.parse(html.ssimulti, function (error, result) {
expect(result).to.equal('<!--#include virtual=\"/head.html\" --><!--#include virtual=\"/header.html\" --><div class=\"slide nodejs\"><h3>100% Node.js</h3><p>We are Node.js experts and the first hosting platform to build our full stack in node. We understand your node application better than anyone.</p></div>');
done();
});
});
it('should be configurable to retain conditional IE comments', function (done) {
var commentable = new Minimize({ conditionals: true });

@@ -104,2 +112,10 @@ commentable.parse(html.ie, function (error, result) {

it('should be configurable to retain multiple conditional IE comments', function (done) {
var commentable = new Minimize({ conditionals: true });
commentable.parse(html.iemulti, function (error, result) {
expect(result).to.equal('<!--[if IE 10]>Special instructions for IE 10 here<![endif]--><!--[if IE 6]>Special instructions for IE 6 here<![endif]--><div class=\"slide nodejs\"><h3>100% Node.js</h3></div>');
done();
});
});
it('should be configurable to retain empty attributes', function (done) {

@@ -106,0 +122,0 @@ var empty = new Minimize({ empty: true });

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