Skip to content

Commit

Permalink
skip links starting with # for scripts and anchors
Browse files Browse the repository at this point in the history
  • Loading branch information
jrit committed Mar 19, 2019
1 parent db9c79f commit 045c32d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"name": "web-resource-inliner",
"description": "Inlines img, script and link tags into the same file.",
"version": "4.3.0",
"version": "4.3.1",
"keywords": [
"inline",
"js",
Expand Down
4 changes: 2 additions & 2 deletions src/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ module.exports = function( options, callback )
( settings.scripts || inlineAttributeRegex.test( found[ 0 ] ) ) )
{
var src = unescape( found[ 2 ] ).trim();
if ( src )
if ( src && src.indexOf( "#" ) !== 0 )
{
tasks.push( replaceScript.bind(
{
Expand Down Expand Up @@ -231,7 +231,7 @@ module.exports = function( options, callback )
( settings.images || inlineAttributeRegex.test( found[ 0 ] ) ) )
{
var src = unescape( found[ 2 ] ).trim();
if ( src ) {
if ( src && src.indexOf( "#" ) !== 0 ) {
tasks.push( replaceImg.bind(
{
element: found[ 0 ],
Expand Down
4 changes: 3 additions & 1 deletion test/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,9 @@ describe( "html", function()

it( "should not try to inline a link that starts with #", function( done )
{
const content = '<link href="#" rel="stylesheet" /><link href="#aaa" rel="stylesheet" />';
const content = '<link href="#" rel="stylesheet" /><link href="#aaa" rel="stylesheet" />'
+ '<img src="#" /><img src="#aaa" />'
+ '<a href="#" /><a href="#aaa" />';

inline.html( {
fileContent: content,
Expand Down

0 comments on commit 045c32d

Please sign in to comment.