Add querystring parameters to all links in html code
npm i html-add-querystring
const haq = require('html-add-querystring');
const html = '<html><body><a href="http://example.com">Test</a></body></html>';
const params = {foo: 'bar'};
const result = haq(html, params);
// result is '<html><head></head><body><a href="http://example.com/?foo=bar">Test</a></body></html>'
Note that the resulting html is somewhat cleaned up (head added in example aboce) because of the underlying use of cheerio.
A good use case for this package is to add UTM Parameters to links in emails. If you process includes rendering emails from templates (potentially pug or others), inlining css with Juice, then this is for you. Simply feed the resulting html through this package with the appropriate utm parameters and all links in the email will have UTM Parameters.
MIT