add _isFQDN_ and change header style

This commit is contained in:
Nathaniel Landau
2021-10-23 23:51:24 -04:00
parent 21d6c9b985
commit a9e8029d9e
5 changed files with 33 additions and 6 deletions

View File

@@ -115,7 +115,11 @@ _alert_() {
reset=""
fi
printf "${_color}[%7s] %s${reset}\n" "${_alertType}" "${_message}"
if [[ ${_alertType} == header ]]; then
printf "${_color}%s${reset}\n" "${_message}"
else
printf "${_color}[%7s] %s${reset}\n" "${_alertType}" "${_message}"
fi
}
_writeToScreen_

View File

@@ -120,6 +120,28 @@ _isEmail_() {
[[ ${1} =~ ${_emailRegex} ]] && return 0 || return 1
}
_isFQDN_() {
# DESC:
# Determines if a given input is a fully qualified domain name
# ARGS:
# $1 (Required): String to validate
# OUTS:
# 0: Successfully validated as FQDN
# 1: Failed to validate as FQDN
# USAGE:
# _isFQDN_ "some.domain.com"
[[ $# == 0 ]] && fatal "Missing required argument to ${FUNCNAME[0]}"
local _input="${1}"
if printf "${_input}" | grep -Pq '(?=^.{4,253}$)(^(?:[a-zA-Z0-9](?:(?:[a-zA-Z0-9\-]){0,61}[a-zA-Z0-9])?\.)+([a-zA-Z]{2,}|xn--[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])$)'; then
return 0
else
return 1
fi
}
_isInternetAvailable_() {
# DESC:
# Check if internet connection is available