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.5 to 1.0.6

9

index.js

@@ -35,3 +35,2 @@ /**

var doc = dom5.parse(source);
var head = dom5.query(doc, pred.hasTagName('head'));
var body = dom5.query(doc, pred.hasTagName('body'));

@@ -58,5 +57,7 @@ var scripts = dom5.queryAll(doc, inlineScriptFinder);

var newScript = dom5.constructors.element('script');
dom5.setAttribute(newScript, 'src', jsFileName);
dom5.append(body, newScript);
if (contents.length > 0) {
var newScript = dom5.constructors.element('script');
dom5.setAttribute(newScript, 'src', jsFileName);
dom5.append(body, newScript);
}

@@ -63,0 +64,0 @@ var html = dom5.serialize(doc);

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

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

@@ -20,25 +20,48 @@ /**

suite('Split API', function() {
var obj;
setup(function() {
obj = crisp.split('', 'foo.js');
});
suite('Default', function () {
var obj;
setup(function() {
obj = crisp.split('<script>var foo = "bar";</script>', 'foo.js');
});
test('return object with js and html properties', function() {
assert.property(obj, 'html');
assert.property(obj, 'js');
});
test('return object with js and html properties', function() {
assert.property(obj, 'html');
assert.property(obj, 'js');
});
test('output html is serialized', function() {
assert.typeOf(obj.html, 'string');
test('output html is serialized', function() {
assert.typeOf(obj.html, 'string');
});
test('output js is linked via <script> in the output html <body>', function() {
var doc = dom5.parse(obj.html);
var outscript = dom5.query(doc, pred.AND(
pred.hasTagName('script'),
pred.hasAttrValue('src', 'foo.js')
));
assert.ok(outscript);
});
});
test('output js is linked via <script> in the output html <body>', function() {
var doc = dom5.parse(obj.html);
var outscript = dom5.query(doc, pred.AND(
pred.hasTagName('script'),
pred.hasAttrValue('src', 'foo.js')
));
assert.ok(outscript);
suite('No JS', function() {
var obj;
setup(function() {
obj = crisp.split('<body>Hello World</body>', 'foo.js');
});
test('js property is empty', function() {
assert.notOk(obj.js);
});
test('output js is NOT linked via <script> in the output html <body>', function() {
var doc = dom5.parse(obj.html);
var outscript = dom5.query(doc, pred.AND(
pred.hasTagName('script'),
pred.hasAttrValue('src', 'foo.js')
));
assert.notOk(outscript);
});
});
});

@@ -45,0 +68,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