Accesso
Bentornato!
Accedi per entrare nella tua dashboard e rimanere aggiornato con le ultime strategie di vendita al dettaglio, approfondimenti operativi e manuali per dirigenti.
Non sei ancora membro? Iscriviti qui.
(() => {
const params = new URLSearchParams(window.location.search);
const redirectTarget = params.get('redirect_to');
// Stop if redirect_to is missing or empty
if (!redirectTarget) {
return;
}
let validatedRedirect;
try {
const targetUrl = new URL(redirectTarget, window.location.origin);
// Only allow http/https URLs on the current domain
if (
!['http:', 'https:'].includes(targetUrl.protocol) ||
targetUrl.origin !== window.location.origin
) {
return;
}
validatedRedirect = targetUrl.href;
} catch {
// Stop if redirect_to is not a valid URL
return;
}
const updateRedirectField = () => {
const field = document.querySelector(
'input[type="hidden"][name="redirect_to"]'
);
if (!field) {
return false;
}
field.value = validatedRedirect;
field.setAttribute('value', validatedRedirect);
return true;
};
// Update immediately if the field already exists
if (updateRedirectField()) {
return;
}
// Otherwise, wait for the embedded form to load
const observer = new MutationObserver(() => {
if (updateRedirectField()) {
observer.disconnect();
}
});
observer.observe(document.documentElement, {
childList: true,
subtree: true
});
})();
