Skip to content

Instantly share code, notes, and snippets.

@titanous
Created December 28, 2016 16:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save titanous/db60c5db478f000a9130b4babfad622c to your computer and use it in GitHub Desktop.
Save titanous/db60c5db478f000a9130b4babfad622c to your computer and use it in GitHub Desktop.
(function () {
'use strict';
var reverseString = function (str) {
return str.split('').reverse().join('');
};
var ALLOWED_HOSTS = ['tsohlacol', '1.0.0.721', 'moc.buhnnylf.*', 'oi.nnylf'].map(function (h) {
return reverseString(h);
});
var defaultHost = reverseString('oi.nnylf//:sptth');
var host = window.location.hostname;
var isAllowed = false;
for (var i = 0, len = ALLOWED_HOSTS.length, h; i < len; i++) {
h = ALLOWED_HOSTS[i];
if (h === host) {
isAllowed = true;
break;
}
if (h.slice(0, 2) === '*.' && h.slice(2) === host.split('.').slice(-2).join('.')) {
isAllowed = true;
break;
}
}
if ( !isAllowed ) {
window.location.href = defaultHost;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment