<script>
// 1. Get the current URL or provide a custom string
const currentUrl = new URL(window.location.href);
// 2. Extract and split the pathname by slashes "/"
// filter(Boolean) safely removes any empty strings from trailing slashes
const wordsArray = currentUrl.pathname.split('/').filter(Boolean);
console.log(wordsArray);
// Redirect to the home page of each initiative.
if (wordsArray.includes('lifehopemoms'))
{
window.location.href = "/lifehopemoms";
}
else if (wordsArray.includes('mephiboshouse'))
{
window.location.href = "/mephiboshouse";
}
else if (wordsArray.includes('mercyhigh'))
{
window.location.href = "/mercyhigh";
}
else if (wordsArray.includes('bethechangeforseniors'))
{
window.location.href = "/bethechangeforseniors";
}
else
{
window.location.href = "/";
}
</script>