mirror of
https://github.com/zhigang1992/AlwaysHTTPS.git
synced 2026-06-12 05:45:06 +08:00
21 lines
344 B
JavaScript
21 lines
344 B
JavaScript
'use strict';
|
|
|
|
(function(){
|
|
function redirectToHttps() {
|
|
window.location.href = window.location.href.replace(/^http:/, 'https:')
|
|
}
|
|
|
|
function checkHttps() {
|
|
if (location.protocol !== 'http:') {
|
|
return
|
|
}
|
|
if (/^[0-9\.]+$/.test(location.host)) {
|
|
return
|
|
}
|
|
redirectToHttps()
|
|
}
|
|
|
|
checkHttps()
|
|
})()
|
|
|