fix domain regex, domains can start with numbers

This commit is contained in:
Matthew Saunders Brown 2024-12-30 10:50:42 -08:00
parent 163e7243da
commit 16f1d09722
2 changed files with 2 additions and 2 deletions

View File

@ -32,7 +32,7 @@ while getopts "hd:" opt; do
d ) # domain name (hostname) to create cert for
domain=${OPTARG,,}
# basic but good enough domain name regex validation
if [[ ! $domain =~ ^(([a-zA-Z](-?[a-zA-Z0-9])*)\.)+[a-zA-Z]{2,}$ ]] ; then
if [[ ! $domain =~ ^(([a-zA-Z0-9](-?[a-zA-Z0-9])*)\.)+[a-zA-Z]{2,}$ ]] ; then
echo "ERROR: Invalid domain name: $1"
exit 1
fi

View File

@ -34,7 +34,7 @@ while getopts "hd:tn" opt; do
d ) # domain name (hostname) to create cert for
domain=${OPTARG,,}
# basic but good enough domain name regex validation
if [[ ! $domain =~ ^(([a-zA-Z](-?[a-zA-Z0-9])*)\.)+[a-zA-Z]{2,}$ ]] ; then
if [[ ! $domain =~ ^(([a-zA-Z0-9](-?[a-zA-Z0-9])*)\.)+[a-zA-Z]{2,}$ ]] ; then
echo "ERROR: Invalid domain name: $1"
exit 1
fi