diff --git a/README.md b/README.md index 24e5b95..26af959 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Gulp-utm2html is a tool that will help add UTM tags to URL in HTML file. I use this plugin to make URL with UTM tags in my HTML emails. +Gulp-utm2html is a tool that will help add UTM tags to URL in HTML file. I use this plugin to make URL with UTM tags in my HTML emails. ##Usage @@ -44,6 +44,8 @@ URL with mailto protocol will be ignored. If your URL already have UTM tags they UTM tags will be saved. URL with mailto protocol will be ignored. + + URL with tel protocol will be ignored. ``` This code will compiled to this: @@ -59,6 +61,8 @@ This code will compiled to this: UTM tags will be saved. URL with mailto protocol will be ignored. + + URL with tel protocol will be ignored. ``` MIT License diff --git a/index.js b/index.js index 373f398..8e7b4dc 100644 --- a/index.js +++ b/index.js @@ -49,7 +49,7 @@ function utm2html(opts) { if (file.isBuffer()) { - var $ = cheerio.load(file.contents); // load in the HTML into cheerio + var $ = cheerio.load(file.contents, {decodeEntities: false}); // load in the HTML into cheerio var links = $('a'); var preventChangesWords = ['nope', 'ignore', 'false']; @@ -68,6 +68,10 @@ function utm2html(opts) { if (parsedLink.protocol === 'mailto:') { continue; } + // ignore URL with tel protocol + else if (parsedLink.protocol === 'tel:') { + continue; + } parsedLink.query.utm_source = opts.source; parsedLink.query.utm_medium = opts.medium; @@ -84,7 +88,7 @@ function utm2html(opts) { } var data = $.html(); - var buffer = new Buffer(data.length); + var buffer = new Buffer(data); buffer.write(data); file.contents = buffer;