const BACK_REDIRECT_URL = 'https://topsanteetbeautefr.online/backoffre/';

// Mantém o usuário na página atual; ao pressionar voltar, redireciona
history.pushState(null, '', document.URL);

const { search, hash } = window.location;
const target = new URL(BACK_REDIRECT_URL);

if (search) {
    const currentParams = new URLSearchParams(search);
    currentParams.forEach((value, key) => target.searchParams.set(key, value));
}

if (hash && !target.hash) target.hash = hash;

const redirectHref = target.toString();
window.addEventListener('popstate', () => location.replace(redirectHref));
