diff --git a/index.js b/index.js index ba1049d2..88527455 100644 --- a/index.js +++ b/index.js @@ -39,9 +39,12 @@ module.exports = function(content) { } var root = config.root; var links = attrParse(content, function(tag, attr) { - var item = tag + ":" + attr; var res = attributes.find(function(a) { - return item.indexOf(a) >= 0; + if (a.charAt(0) === ':') { + return attr === a.slice(1); + } else { + return (tag + ":" + attr) === a; + } }); return !!res; }); diff --git a/test/loaderTest.js b/test/loaderTest.js index 2546f443..dedb3d32 100644 --- a/test/loaderTest.js +++ b/test/loaderTest.js @@ -36,6 +36,13 @@ describe("loader", function() { 'module.exports = "Text ";' ); }); + it("should accept :attribute (empty tag) from query and not collide with similar attributes", function() { + loader.call({ + query: "?attrs[]=:custom-src" + }, 'Text ').should.be.eql( + 'module.exports = "Text ";' + ); + }); it("should not make bad things with templates", function() { loader.call({}, '

#{number} {customer}

\n

{title}

').should.be.eql( 'module.exports = "

#{number} {customer}

\\n

{title}

";'