Skip to content

Commit

Permalink
fix: ignore attribute if mailto: is present (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianomorando authored and michael-ciniawsky committed Sep 29, 2017
1 parent dac21c2 commit 4b13d4c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ module.exports = function(content) {
content = [content];
links.forEach(function(link) {
if(!loaderUtils.isUrlRequest(link.value, root)) return;

if (link.value.indexOf('mailto:') > -1 ) return;

var uri = url.parse(link.value);
if (uri.hash !== null && uri.hash !== undefined) {
Expand Down
5 changes: 5 additions & 0 deletions test/loaderTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ describe("loader", function() {
'module.exports = "<img src=\\"" + require("./icons.svg") + "#hash\\">";'
);
});
it("should ignore anchor with 'mailto:' in the href attribute", function() {
loader.call({}, '<a href="mailto:username@exampledomain.com"></a>').should.be.eql(
'module.exports = "<a href=\\"mailto:username@exampledomain.com\\"></a>";'
);
});
it("should ignore interpolations by default", function() {
loader.call({}, '<img src="${"Hello " + (1+1)}">').should.be.eql(
'module.exports = "<img src=\\"${\\"Hello \\" + (1+1)}\\">";'
Expand Down

0 comments on commit 4b13d4c

Please sign in to comment.