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

crisper

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crisper - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

13

index.js

@@ -23,3 +23,4 @@ /**

),
pred.hasAttrValue('type', 'application/javascript')
pred.hasAttrValue('type', 'application/javascript'),
pred.hasAttrValue('type', 'text/javascript')
),

@@ -31,2 +32,4 @@ pred.NOT(

var noSemiColonInsertion = /\/\/|;\s*$|\*\/\s*$/;
function split(source, jsFileName) {

@@ -47,3 +50,7 @@ var doc = dom5.parse(source);

}
contents.push(dom5.getTextContent(sn));
var content = dom5.getTextContent(sn);
if (!noSemiColonInsertion.test(content)) {
content += ';';
}
contents.push(content);
});

@@ -57,3 +64,3 @@

// newline + semicolon should be enough to capture all cases of concat
var js = contents.join('\n;');
var js = contents.join('\n');

@@ -60,0 +67,0 @@ return {

{
"name": "crisper",
"version": "1.0.3",
"version": "1.0.4",
"description": "Make an HTML file with inline scripts CSP compliant",

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

@@ -6,3 +6,37 @@ # Crisper

Command line usage:
cat index.html | crisper -h build.html -j build.js
crisper --source index.html --html build.html --js build.js
Library usage:
var output = crisper(htmlString, jsOutputFileName);
fs.writeFile(htmlOutputFileName, output.html, 'utf-8', ...);
fs.writeFile(jsOutputFileName, output.js, 'utf-8', ...);
## Usage with Vulcanize
When using [vulcanize](https://github.com/Polymer/vulcanize), crisper can handle
the html string output directly and write the CSP seperated files on the command
line
vulcanize index.html --inline-script | crisper --html build.html --js
build.js
Or programmatically
vulcanize.process('index.html', function(err, html) {
if (err) {
return cb(err);
} else {
var out = crisper.split(html, jsFilename)
cb(null, out.html, out.js);
}
});
## Build Tools
- [gulp-crisper](https://npmjs.com/package/gulp-crisper)
- *No grunt plugin yet, will you write it?*
- *No broccoli plugin yet, will you write it?*

@@ -58,3 +58,5 @@ /**

var twoIndex = script.indexOf('two');
var threeIndex = script.indexOf('three');
assert.ok(oneIndex < twoIndex);
assert.ok(twoIndex < threeIndex);
});

@@ -76,7 +78,13 @@

test('Newline Semicolon should be used for concating', function() {
test('Newline Semicolon should be used for concating, when necessary', function() {
var script = obj.js;
var expected = '//inline comment\n;var next_statement';
var expected = '//inline comment\nvar next_statement=\'found\';';
var actual = script.indexOf(expected);
assert(actual > -1);
assert(actual > -1, 'semicolon in the wrong spot');
expected = 'var three = "three"; //still supported, but don\'t use!';
actual = script.indexOf(expected);
assert(actual > -1, 'semicolon inserted incorrectly');
expected = '//# sourceMappingURL=/dev/null';
actual = script.indexOf(expected);
assert(actual > -1, 'sourcemap had semicolon insertion incorrectly');
});

@@ -83,0 +91,0 @@ });

Sorry, the diff of this file is not supported yet

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