Add referral id decorator for JS
[MAILPOET-2182]
This commit is contained in:
committed by
M. Shull
parent
e21515c460
commit
226265b20a
16
assets/js/src/referral_url_decorator.jsx
Normal file
16
assets/js/src/referral_url_decorator.jsx
Normal 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;
|
Reference in New Issue
Block a user