I have the following script:
if (window.location.href.indexOf('env=P')) {
env = 'P';
console.log("P");
} else {
env = 'A';
console.log("A");
}
env is always equal to P no matter what the url is. I am quite sure I have used indexOf before for uri’s but am not sure the issue here.
That’s because indexOf doesn’t return 0 and is therefore evaluated as true. Try changing to