Array of Domains to Exclude
by TheFiddler
HTML
<button id="go">Check</button>
<div id="result"></div>
JavaScript
function donotpushlinks(linkpattern){
var blacklist = [
"twitter"
,"facebook"
,"tumblr"
,"javascript"
];
var re = new RegExp('\\b' + blacklist.join("|") + '\\b', 'i');
return(linkpattern.match(re) != null);
}
var b = donotpushlinks('http:twitter.com/test');
$("#go").click(function() {
//test patterns
if (b)
{
console.log('external link: ' + b + ' ' + this.href);
}
else
{
console.log('internal ' + b + ' ' + this.href);
}
});