Files
30-seconds-of-code/snippets/httpsRedirect.md
2017-12-21 12:03:56 +05:30

9 lines
313 B
Markdown

### 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]);
}
```