Added support for FQDNs in simpledemo.html
This commit is contained in:
parent
75e7d76d26
commit
cf0f5944ac
@ -530,8 +530,11 @@
|
||||
<script src='https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js'
|
||||
integrity='sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL' crossorigin='anonymous'></script>
|
||||
<script type="text/javascript">
|
||||
function isValidIP(ipaddress) {
|
||||
if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipaddress)) {
|
||||
function isValidIPorFQDN(address) {
|
||||
if (/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(address)) { // regex from https://www.w3resource.com/javascript/form/ip-address-validation.php
|
||||
return true;
|
||||
}
|
||||
if (/^(?!:\/\/)(?!.{256,})(([a-z0-9][a-z0-9_-]*?\.)+?[a-z]{2,6}?)$/i.test(address)) { // regex from https://stackoverflow.com/questions/16463666/javascript-regex-to-match-fully-qualified-domain-name-without-protocol-optiona
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -774,7 +777,7 @@
|
||||
setInterval(updateStrings, 10000);
|
||||
}
|
||||
window.onload = function(e) {
|
||||
if (document.cookie == "" || !isValidIP(document.cookie)) {
|
||||
if (document.cookie == "" || !isValidIPorFQDN(document.cookie)) {
|
||||
var selectIPModal = new bootstrap.Modal(document.getElementById('selectIPAddressModal'), {});
|
||||
selectIPModal.show();
|
||||
|
||||
@ -782,7 +785,7 @@
|
||||
|
||||
function configButtonEventListener(hideModalOnSuccess) {
|
||||
var ipAddressEntered = document.getElementById('ipAdressInput').value;
|
||||
if(isValidIP(ipAddressEntered)) {
|
||||
if(isValidIPorFQDN(ipAddressEntered)) {
|
||||
var request = new XMLHttpRequest();
|
||||
request.onreadystatechange = function() {
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
@ -811,7 +814,7 @@
|
||||
const ipAdressModalOkBtn = document.getElementById('ipAdressModalOkBtn');
|
||||
ipAdressModalOkBtn.addEventListener('click', () => { configButtonEventListener(true); });
|
||||
|
||||
} else if (isValidIP(document.cookie)) setupSite();
|
||||
} else if (isValidIPorFQDN(document.cookie)) setupSite();
|
||||
} // end of onload function
|
||||
</script>
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user