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

web-resource-inliner

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web-resource-inliner - npm Package Compare versions

Comparing version 3.0.0 to 4.0.0

test/cases/assets/ie.css

2

HISTORY.md
## Release History
* 2016-11-17 v4.0.0 Breaking: min engine is now v4.2; Feat: escape `"</script>"` strings in script tags, improved multiline support
* 2016-09-07 v3.0.0 Breaking: Removed `cssmin` option; Feat: New `linkTransform` option which can replace cssmin, and is more flexible
* 2016-03-30 v2.0.0 Feat: SVG `use` inlining; Feat: requestTransform; Fix: default gzip handling

@@ -3,0 +5,0 @@ * 2015-11-03 v1.2.1 Fix: HTTP status codes undefined

23

package.json

@@ -9,3 +9,3 @@ {

"description": "Inlines img, script and link tags into the same file.",
"version": "3.0.0",
"version": "4.0.0",
"keywords": [

@@ -27,18 +27,17 @@ "inline",

"engines": {
"node": ">=4.0.0"
"node": ">=4.2.0"
},
"devDependencies": {
"faux-jax": "^5.0.0",
"istanbul": "^0.3.5",
"mime-types": "^2.1.7",
"mocha": "^2.0.1"
"faux-jax": "^5.0.5",
"istanbul": "^0.4.5",
"mime-types": "^2.1.12",
"mocha": "^3.1.2"
},
"dependencies": {
"async": "^1.5.2",
"async": "^2.1.2",
"chalk": "^1.1.3",
"datauri": "~0.2.0",
"htmlparser2": "^3.8.3",
"lodash.constant": "^3.0.0",
"lodash.unescape": "^4.0.0",
"request": "^2.72.0",
"datauri": "^1.0.4",
"htmlparser2": "^3.9.2",
"lodash.unescape": "^4.0.1",
"request": "^2.78.0",
"xtend": "^4.0.0"

@@ -45,0 +44,0 @@ },

@@ -67,5 +67,2 @@ # web-resource-inliner[![build status](https://secure.travis-ci.org/jrit/web-resource-inliner.png)](http://travis-ci.org/jrit/web-resource-inliner)

#### `cssmin`, Boolean, default `false`
If cssmin is assigned `true`, CSS will be minified before inlined.
#### `strict`, Boolean, default `false`

@@ -72,0 +69,0 @@ When strict is `true`, a missing resource will cause the inliner to halt and return an error in the callback. The default behavior is to log a warning to the console and continue inlining with the available resources, which is more similar to how a web page behaves.

@@ -6,3 +6,2 @@ "use strict";

var path = require( "path" );
var constant = require( "lodash.constant" );
var inline = require( "./util" );

@@ -36,3 +35,3 @@

var re = new RegExp( "url\\(\\s?[\"']?(" + inline.escapeSpecialChars( args.src ) + ")[\"']?\\s?\\);", "g" );
result = result.replace( re, constant( css ) );
result = result.replace( re, () => css );

@@ -47,3 +46,3 @@ return callback( null );

var re = new RegExp( "url\\(\\s?[\"']?(" + inline.escapeSpecialChars( src ) + ")[\"']?\\s?\\);", "g" );
result = result.replace( re, constant( css ) );
result = result.replace( re, () => css );
};

@@ -60,9 +59,11 @@

var matches = {};
var src;
while( ( found = urlRegex.exec( result ) ) !== null )
{
var src = found[ 1 ];
src = found[ 1 ];
matches[ src ] = true;
}
for( var src in matches )
for( src in matches )
{

@@ -69,0 +70,0 @@ if( !inline.isRemotePath( src ) && !inline.isBase64Path( src ) )

"use strict";
var path = require( "path" );
var constant = require( "lodash.constant" );
var unescape = require( "lodash.unescape" );

@@ -43,9 +42,11 @@ var xtend = require( "xtend" );

if( !content || typeof( args.limit ) === "number" && js.length > args.limit * 1000 )
if( !content || typeof( args.limit ) === "number" && content.length > args.limit * 1000 )
{
return callback( null );
}
var html = "<script" + ( args.attrs ? " " + args.attrs : "" ) + ">\n" + content + "\n</script>";
var html = content.toString();
html = html.replace( /<\/script>/gmi, "<\\/script>" );
html = "<script" + ( args.attrs ? " " + args.attrs : "" ) + ">\n" + html + "\n</script>";
var re = new RegExp( inline.escapeSpecialChars( args.element ), "g" );
result = result.replace( re, constant( html ) );
result = result.replace( re, () => html );
return callback( null );

@@ -98,5 +99,7 @@ };

}
var html = "<style" + ( args.attrs ? " " + args.attrs : "" ) + ">\n" + content + "\n</style>";
var html = content.toString();
html = html.replace( /<\/script>/gmi, "<\\/script>" );
html = "<style" + ( args.attrs ? " " + args.attrs : "" ) + ">\n" + html.replace( /\/\*[\s]*--[\s]*>*/gm, "/* - ->" ) + "\n</style>";
var re = new RegExp( inline.escapeSpecialChars( args.element ), "g" );
result = result.replace( re, constant( html ) );
result = result.replace( re, () => html );
return callback( null );

@@ -132,3 +135,3 @@ } );

var re = new RegExp( inline.escapeSpecialChars( args.element ), "g" );
result = result.replace( re, constant( html ) );
result = result.replace( re, () => html );
return callback( null );

@@ -167,3 +170,3 @@ } );

var re = new RegExp( inline.escapeSpecialChars( args.element ), "g" );
result = result.replace( re, constant( use ) );
result = result.replace( re, () => use );
}

@@ -185,4 +188,5 @@

var inlineAttributeIgnoreRegex = new RegExp( settings.inlineAttribute + "-ignore", "i" );
var relStylesheetAttributeIgnoreRegex = new RegExp( "stylesheet", "i" );
var scriptRegex = /<script\b[\s\S]+?\bsrc\s*=\s*("|')([\s\S]+?)\1[\s\S]*?>\s*<\/script>/gi;
var scriptRegex = /<script\b[^>]+?\bsrc\s*=\s*("|')([\s\S]+?)\1[\s\S]*?>[\s\w\S]*?(?=<\/script>)<\/script>/gi;
while( ( found = scriptRegex.exec( result ) ) !== null )

@@ -203,6 +207,7 @@ {

var linkRegex = /<link\b[\s\S]+?\bhref\s*=\s*("|')([\s\S]+?)\1[\s\S]*?>/gi;
var linkRegex = /<link\b[\s\S]+?\bhref\s*=\s*("|')([\s\S]*?)\1[\s\S]*?>/gm;
while( ( found = linkRegex.exec( result ) ) !== null )
{
if( !inlineAttributeIgnoreRegex.test( found[ 0 ] ) &&
relStylesheetAttributeIgnoreRegex.test( found[ 0 ] ) &&
( settings.links || inlineAttributeRegex.test( found[ 0 ] ) ) )

@@ -220,3 +225,3 @@ {

var imgRegex = /<img\b[\s\S]+?\bsrc\s*=\s*("|')([\s\S]+?)\1[\s\S]*?>/gi;
var imgRegex = /<img\b[\s\S]+?\bsrc\s*=\s*("|')([\s\S]*?)\1[\s\S]*?>/gm;
while( ( found = imgRegex.exec( result ) ) !== null )

@@ -223,0 +228,0 @@ {

@@ -0,0 +0,0 @@ /*

@@ -19,3 +19,2 @@ "use strict";

links: true,
cssmin: false,
strict: false,

@@ -44,3 +43,3 @@ relativeTo: "",

{
return str.replace( /(\/|\.|\$|\^|\{|\[|\(|\||\)|\*|\+|\?|\\)/g, "\\$1" );
return str.replace( /(\/|\.|\$|\^|\{|\[|\(|\||\)|\*|\+|\?|\\)/gm, "\\$1" );
};

@@ -65,2 +64,3 @@

var attrs = tagMarkup
.replace( /(<[\s\S]*?(?=\>))([\s\S]*?(?=\<\/))(<\/[\w\W]>)?/gm, "$1>$3" )
.replace( /^<[^\s>]*/, "" )

@@ -173,4 +173,8 @@ .replace( /\/?>/, "" )

{
if( util.isRemotePath( settings.relativeTo ) )
if( !src || util.srcIsCid( src ) )
{
callback( null );
}
else if( util.isRemotePath( settings.relativeTo ) )
{
getRemote( url.resolve( settings.relativeTo, src ), settings, callback, true );

@@ -189,2 +193,7 @@ }

util.srcIsCid = function( src )
{
return src.match( /^cid:/ );
};
util.handleReplaceErr = function( err, src, strict, callback )

@@ -191,0 +200,0 @@ {

@@ -1,1 +0,4 @@

console.log('test');
console.log('test');
winprint.document.write('</div></form></body></html>');
winprint.document.write('<script>window.print();');
winprint.document.write('</script>');

@@ -198,3 +198,3 @@ /*eslint-env mocha */

{
done( null, "/*inserted*/\n" + content );
done( null, content );
}

@@ -201,0 +201,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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