Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -44,6 +44,8 @@ URL with mailto protocol will be ignored. If your URL already have UTM tags they
UTM tags will be saved.</a>
<a href="mailto:[email protected]">
URL with mailto protocol will be ignored.</a>
<a href="tel:07700900000">
URL with tel protocol will be ignored.</a>
```

This code will compiled to this:
Expand All @@ -59,6 +61,8 @@ This code will compiled to this:
UTM tags will be saved.</a>
<a href="mailto:[email protected]">
URL with mailto protocol will be ignored.</a>
<a href="tel:07700900000">
URL with tel protocol will be ignored.</a>
```

MIT License
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand All @@ -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;
Expand All @@ -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;

Expand Down