Snippet to perform HTTPS redirect

This commit is contained in:
Arjun Mahishi
2017-12-21 12:03:56 +05:30
parent 0995936760
commit 2305ea4ed9

View File

@ -0,0 +1,9 @@
### httpsRedirect
Redirects the page to HTTPS if its currently in HTTP. Also, pressing the back button doesn't take it back to the HTTP page as its replaced in the history.
```js
const httpsRedirect = () => {
if(location.protocol !== "https:") location.replace("https://" + location.href.split("//")[1]);
}
```