web-resource-inliner
Advanced tools
Comparing version 4.0.0 to 4.1.0
## 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 | ||
* 2015-11-03 v1.2.1 Fix: HTTP status codes undefined | ||
* 2015-10-23 v1.2.0 Enhancement: Strip value of data-inline(-ignore) attributes | ||
* 2015-10-23 v1.1.5 Fix: Unescape HTML entities in the URLs extracted from attributes. Fix: Move callback outside of `try` block | ||
* 2015-09-28 v1.1.4 Fixes relativeTo support for images | ||
* 2015-07-23 v1.1.2 Multiline support | ||
* 2015-04-19 v1.1.1 Fixes to regex usage from PRs 3 and 4 | ||
* 2015-02-27 v1.1.0 Enhancement: add `strict` option and change behavior to be `false` by default. Previous behavior was equivalent to `strict=true`. | ||
* 2015-02-26 v1.0.2 Fix: pass file missing errors up through callbacks | ||
* 2015-02-18 v1.0.1 use relativeTo with URLs to resolve web paths; use https: as default when paths start with // | ||
* 2015-01-01 v1.0.0 initial release: Forked and rewritten from grunt-inline with the goal of providing additional use cases and a new API | ||
### 2017-03-06 *v4.1.0* | ||
Fixes: Use `rebaseRelativeTo` if it is defined; Fix to rebase urls that appear on the same line; Support fragment URLs when getting inline file path. [PR Ref](https://github.com/jrit/web-resource-inliner/pull/27) | ||
### 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 | ||
### 2015-11-03 *v1.2.1* | ||
Fix: HTTP status codes undefined | ||
### 2015-10-23 *v1.2.0* | ||
Enhancement: Strip value of data-inline(-ignore) attributes | ||
### 2015-10-23 *v1.1.5* | ||
Fix: Unescape HTML entities in the URLs extracted from attributes. Fix: Move callback outside of `try` block | ||
### 2015-09-28 *v1.1.4* | ||
Fixes relativeTo support for images | ||
### 2015-07-23 *v1.1.2* | ||
Multiline support | ||
### 2015-04-19 *v1.1.1* | ||
Fixes to regex usage from PRs 3 and 4 | ||
### 2015-02-27 *v1.1.0* | ||
Enhancement: add `strict` option and change behavior to be `false` by default. Previous behavior was equivalent to `strict=true`. | ||
### 2015-02-26 *v1.0.2* | ||
Fix: pass file missing errors up through callbacks | ||
### 2015-02-18 *v1.0.1* | ||
use relativeTo with URLs to resolve web paths; use https: as default when paths start with // | ||
### 2015-01-01 *v1.0.0* | ||
initial release: Forked and rewritten from grunt-inline with the goal of providing additional use cases and a new API |
{ | ||
"author": { | ||
"name": "Jarrett Widman", | ||
"email": "jarrett.widman@vokal.io", | ||
"url": "https://github.com/jrit" | ||
@@ -9,3 +8,3 @@ }, | ||
"description": "Inlines img, script and link tags into the same file.", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"keywords": [ | ||
@@ -12,0 +11,0 @@ "inline", |
@@ -32,4 +32,4 @@ "use strict"; | ||
var css = "url(\"" + datauriContent + "\");"; | ||
var re = new RegExp( "url\\(\\s?[\"']?(" + inline.escapeSpecialChars( args.src ) + ")[\"']?\\s?\\);", "g" ); | ||
var css = "url(\"" + datauriContent + "\")"; | ||
var re = new RegExp( "url\\(\\s?[\"']?(" + inline.escapeSpecialChars( args.src ) + ")[\"']?\\s?\\)", "g" ); | ||
result = result.replace( re, () => css ); | ||
@@ -43,4 +43,4 @@ | ||
{ | ||
var css = "url(\"" + path.join( settings.rebaseRelativeTo, src ).replace( /\\/g, "/" ) + "\");"; | ||
var re = new RegExp( "url\\(\\s?[\"']?(" + inline.escapeSpecialChars( src ) + ")[\"']?\\s?\\);", "g" ); | ||
var css = "url(\"" + path.join( settings.rebaseRelativeTo, src ).replace( /\\/g, "/" ) + "\")"; | ||
var re = new RegExp( "url\\(\\s?[\"']?(" + inline.escapeSpecialChars( src ) + ")[\"']?\\s?\\)", "g" ); | ||
result = result.replace( re, () => css ); | ||
@@ -53,3 +53,4 @@ }; | ||
var urlRegex = /url\(\s?["']?([^)'"]+)["']?\s?\);.*/gi; | ||
var urlRegex = /url\(\s?["']?([^)'"]+)["']?\s?\).*/i; | ||
var index = 0; | ||
@@ -61,6 +62,7 @@ if( settings.rebaseRelativeTo ) | ||
while( ( found = urlRegex.exec( result ) ) !== null ) | ||
while( ( found = urlRegex.exec( result.substring(index) ) ) !== null ) | ||
{ | ||
src = found[ 1 ]; | ||
matches[ src ] = true; | ||
index = found.index + index + 1; | ||
} | ||
@@ -80,3 +82,4 @@ | ||
while( ( found = urlRegex.exec( result ) ) !== null ) | ||
index = 0; | ||
while( ( found = urlRegex.exec( result.substring(index) ) ) !== null ) | ||
{ | ||
@@ -92,2 +95,3 @@ if( !inlineAttributeIgnoreCommentRegex.test( found[ 0 ] ) && | ||
} | ||
index = found.index + index + 1; | ||
} | ||
@@ -94,0 +98,0 @@ |
@@ -89,3 +89,3 @@ "use strict"; | ||
fileContent: content.toString(), | ||
rebaseRelativeTo: path.relative( settings.relativeTo, path.join( settings.relativeTo, args.src, ".." + path.sep ) ) | ||
rebaseRelativeTo: path.relative( settings.relativeTo, settings.rebaseRelativeTo || path.join( settings.relativeTo, args.src, ".." + path.sep ) ) | ||
} ); | ||
@@ -92,0 +92,0 @@ |
@@ -136,3 +136,3 @@ "use strict"; | ||
src = src.replace( /^\//, "" ); | ||
return path.resolve( relativeTo, src ).replace( /\?.*$/, "" ); | ||
return path.resolve( relativeTo, src ).replace( /[\?#].*$/, "" ); | ||
}; | ||
@@ -139,0 +139,0 @@ |
@@ -155,2 +155,18 @@ /*eslint-env mocha */ | ||
} ); | ||
it( "should rebase inline local links relative to", function( done ) | ||
{ | ||
var expected = readFile( "test/cases/css-rebase_out.html" ); | ||
inline.html( { | ||
fileContent: readFile( "test/cases/css-rebase.html" ), | ||
relativeTo: "test/cases/", | ||
rebaseRelativeTo: "test/cases/assets/fonts" | ||
}, | ||
function( err, result ) | ||
{ | ||
testEquality( err, result, expected, done ); | ||
} | ||
); | ||
} ); | ||
} ); | ||
@@ -583,2 +599,18 @@ | ||
} ); | ||
it( "should rebase local urls", function( done ) | ||
{ | ||
var expected = readFile( "test/cases/css-rebase_out.css" ); | ||
inline.css( { | ||
fileContent: readFile( "test/cases/css-rebase.css" ), | ||
rebaseRelativeTo: "assets", | ||
images: false | ||
}, | ||
function( err, result ) | ||
{ | ||
testEquality( err, result, expected, done ); | ||
} | ||
); | ||
} ); | ||
} ); | ||
@@ -585,0 +617,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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
236846
76
1124