Last active
February 1, 2016 22:04
-
-
Save aripalo/e8205c09e19a10ea2649 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(w) { | |
try { | |
var isHttps = w.location.protocol === "https:"; | |
var hasSniSupport = true;//we default to true | |
var ua = window.navigator.userAgent; | |
var isInternetExplorerOnWinXpOrOlder = /MSIE.*Windows\s?((NT)?\s?(([0-5]\.\d))|XP|98|95|NT;)/i.test(ua); | |
var isAndroid3XorOlder = /Android [0-3]\./i.test(ua); | |
var isSymbian = /(SymbianOS|Series40|Series60)/i.test(ua); | |
var isBlackBerry = /BlackBerry/i.test(ua); | |
if(isInternetExplorerOnWinXpOrOlder || isAndroid3XorOlder || isSymbian || isBlackBerry) hasSniSupport = false; | |
if(!isHttps && hasSniSupport) { | |
//alert('Browser probably supports SNI, will "soft redirect" to secure https site'); | |
w.location.href = "https:" + w.location.href.substring(w.location.protocol.length); | |
} | |
} catch(e) { | |
//alert('Something went wrong with SNI "soft redirect": '+e.message) | |
} | |
}(window)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment