I have an array of "banned domains", and I'm trying to find an easy way to check if a particular email is from one of those domains. Consider the following:
var bannedDoms = ["gmail.com", "hotmail.com", ".le.salesforce.com"]
if(bannedDoms.indexOf(email.split("@")[1]) === -1){
// It's a good domain!
}
This works fine, except for the last example, as the salesforce emails are from weird domains like emailtosalesforce@t-1l9sefi2sef5wlowk59bvm0uuh78mkdfuhioamfu7vxv8agjjh.o-h7zieac.na17.le.salesforce.com - the common factor being that they all have .le.salesforce.com in the address.
Searching via Array.prototype.indexOf() is quite an elegant solution and I'd like to use something similar if possible - but to also catch parts of strings, rather than a whole string match.
What's the most efficient and simple way to do this in Javascript?