Simplify hostname_regex

`[a-z0-9\.\*-]+` includes `\.` and `[a-z0-9\*-]+`.
So I think `^([a-z0-9\.\*-]+\.)*[a-z0-9\*-]+$` means last char is `[a-z0-9\*-]`
and other optional chars are `[a-z0-9\.\*-]*`.
This commit is contained in:
Kazuhiro NISHIYAMA
2019-05-23 23:23:10 +09:00
parent 3a2bdd83f8
commit 082e9458e5

View File

@@ -312,7 +312,7 @@ is_global_vhost_enabled() {
is_valid_hostname() {
declare desc="return 0 if argument is a valid hostname; else return 1"
local hostname_string="${1,,}"
local hostname_regex='^([a-z0-9\.\*-]+\.)*[a-z0-9\*-]+$'
local hostname_regex='^[a-z0-9\.\*-]*[a-z0-9\*-]$'
if [[ $hostname_string =~ $hostname_regex ]]; then
return 0
else