Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<script>
/* Create an anonymous function */
(function() {
/* 1. Define default protocol */
protocolToUse = "http";
/* 2. Identify current page protocol */
currentProtocol = doc.loc.protocol;
/* 3. Identify the protocol the page should use */
if(window.location.domain.test(/ge\.com$/)) {
/* Staging, so use HTTP */
protocolToUse = “http”;
}
else if(typeof useSSL === 'boolean') {
/* If a specific override is in place, use this */
protocolToUse = useSSL;
}
else if(document.location.test('/form/')) {
/* If no specific override, see if it matches one of the ‘special’ folders */
protocolToUse = "https";
}
/* 4. If the current protocol is not the protocol to use, then change the location (including any querystring or hash) */
if currentProtocol!=protocolToUse {
location = protocolToUse & domain & path...;
}
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment