Use JS URL api to manipulate URL in referral id decorator

[MAILPOET-2182]
This commit is contained in:
Rostislav Wolny
2019-08-13 13:16:54 +02:00
committed by M. Shull
parent 5d665f982e
commit 72f5a6e02e

View File

@ -2,15 +2,9 @@ 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();
const refUrl = new URL(url);
refUrl.searchParams.set('ref', window.mailpoet_referral_id);
return refUrl.toString();
};
export default addReferralId;