Skip to content

Commit 4b13d4c

Browse files
fix: ignore attribute if mailto: is present (#145)
1 parent dac21c2 commit 4b13d4c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

index.js

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ module.exports = function(content) {
5353
content = [content];
5454
links.forEach(function(link) {
5555
if(!loaderUtils.isUrlRequest(link.value, root)) return;
56+
57+
if (link.value.indexOf('mailto:') > -1 ) return;
5658

5759
var uri = url.parse(link.value);
5860
if (uri.hash !== null && uri.hash !== undefined) {

test/loaderTest.js

+5
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ describe("loader", function() {
150150
'module.exports = "<img src=\\"" + require("./icons.svg") + "#hash\\">";'
151151
);
152152
});
153+
it("should ignore anchor with 'mailto:' in the href attribute", function() {
154+
loader.call({}, '<a href="mailto:[email protected]"></a>').should.be.eql(
155+
'module.exports = "<a href=\\"mailto:[email protected]\\"></a>";'
156+
);
157+
});
153158
it("should ignore interpolations by default", function() {
154159
loader.call({}, '<img src="${"Hello " + (1+1)}">').should.be.eql(
155160
'module.exports = "<img src=\\"${\\"Hello \\" + (1+1)}\\">";'

0 commit comments

Comments
 (0)