Redirect depending on referrer
exports.endpoint = (request, response) => {
response.end(`<script>
const ref = document.referrer;
const redirect = url => {
window.alert(\`You will be redirected to\n${url}\`);
window.location.href = url;
};
if (-1 !== ref.indexOf('WNNJJrm') || -1 !== ref.indexOf('slack.com'))
redirect('https://www.iana.org/');
else if (-1 !== ref.indexOf('NWWMMGe') || -1 !== ref.indexOf('google.com'))
redirect('https://www.ietf.org/');
else
window.alert(\`Unknown referrrer\n(${ref})\`);
</script>`);
};
no comments