Add referral id decorator for JS

[MAILPOET-2182]
This commit is contained in:
Rostislav Wolny
2019-08-07 13:33:25 +02:00
committed by M. Shull
parent e21515c460
commit 226265b20a

View File

@ -0,0 +1,16 @@
const addReferralId = (url) => {
if (!window.mailpoet_referral_id) {
return url;
}
const parser = document.createElement('a');
parser.href = url;
parser.search += parser.search ? '&' : '?';
parser.search += `ref=${encodeURIComponent(window.mailpoet_referral_id)}`;
return parser.toString();
// const refUrl = new URL(url);
// refUrl.searchParams.set('ref', window.mailpoet_referral_id);
// return refUrl.toString();
};
export default addReferralId;