use perl to validate domain

This commit is contained in:
Joe 2019-12-26 16:30:11 -06:00
parent 134638b021
commit b336af9376
Signed by: joe
GPG Key ID: 8595A3F8F2CE1B74
1 changed files with 11 additions and 0 deletions

View File

@ -17,6 +17,16 @@ UnixTimeMs() {
unix_time_ms="$(($(date -d "$1" +'%s') * 1000))"
}
DomainCheck() {
local result=$(perl -pe 's/(?=^.{4,253}$)(^((?!-)[a-zA-Z0-9-]{1,63}(?<!-)\.)+[a-zA-Z]{2,63}$)/pass/g' <<< "$1")
if [ "$result" = "pass" ]; then
return 0;
else
echo -e 'Error: Not a valid domain.\n'
exit 1;
fi
}
EchoVersion() {
echo $version
}
@ -24,6 +34,7 @@ EchoVersion() {
main() {
EchoVersion;
UserInput;
DomainCheck "$domain';
UnixTimeMs "$time";
ExecutePurge "$domain" "$unix_time_ms" "$token"
}