Skip to content

Instantly share code, notes, and snippets.

@mephraums
Created May 28, 2014 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mephraums/7a4ab59238fe2def9d95 to your computer and use it in GitHub Desktop.
Save mephraums/7a4ab59238fe2def9d95 to your computer and use it in GitHub Desktop.
<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