Skip to content

Commit 045c32d

Browse files
committed
skip links starting with # for scripts and anchors
1 parent db9c79f commit 045c32d

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
},
66
"name": "web-resource-inliner",
77
"description": "Inlines img, script and link tags into the same file.",
8-
"version": "4.3.0",
8+
"version": "4.3.1",
99
"keywords": [
1010
"inline",
1111
"js",

src/html.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ module.exports = function( options, callback )
190190
( settings.scripts || inlineAttributeRegex.test( found[ 0 ] ) ) )
191191
{
192192
var src = unescape( found[ 2 ] ).trim();
193-
if ( src )
193+
if ( src && src.indexOf( "#" ) !== 0 )
194194
{
195195
tasks.push( replaceScript.bind(
196196
{
@@ -231,7 +231,7 @@ module.exports = function( options, callback )
231231
( settings.images || inlineAttributeRegex.test( found[ 0 ] ) ) )
232232
{
233233
var src = unescape( found[ 2 ] ).trim();
234-
if ( src ) {
234+
if ( src && src.indexOf( "#" ) !== 0 ) {
235235
tasks.push( replaceImg.bind(
236236
{
237237
element: found[ 0 ],

test/spec.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,9 @@ describe( "html", function()
525525

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

530532
inline.html( {
531533
fileContent: content,

0 commit comments

Comments
 (0)