Blocking Redirect based on excluded IP

1
2
3
4
5
6
7
8
9
10
11
12
13
var redirectIPExcludeList = ["213.235.0.105","213.235.0.106",
"86.12.149.50","79.173.148.50","207.164.206.66","1.0.0.255"]
var returnedIp = "213.235.0.106"
 
for(var i =0; i< redirectIPExcludeList.length; i++){
    if(returnedIp != redirectIPExcludeList[i]){
        alert('failed : '+ redirectIPExcludeList[i] + ' != ' +returnedIp );
    }else{
        alert('Perfect Match : '+ redirectIPExcludeList[i] + ' = ' +returnedIp);
        break;
    }
 
}
This was built in demandware. I developed a framework where the business managers from our global offices entered their IP addresses to prevent the default redirect. The redirect project works on an idea to check the clients IP address and then redirect the user to the respective country website. If the IP is coming from the US and the excluded list no redirect happens.