Skip to content
This repository has been archived by the owner on Apr 3, 2018. It is now read-only.

Commit

Permalink
Fix #39 + Fix issue with date format detection
Browse files Browse the repository at this point in the history
  • Loading branch information
funilrys committed Jul 11, 2017
1 parent c027543 commit 628a790
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions funceble
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ getExpirationDate(){

# Here's a list of words the ${content} have to match to get the
# expiration date from the whois record of domain
local toMatch=('expire:' 'Expiration Date:' 'expire on:' 'Expiry Date:' 'free-date' 'expires:' 'Expiration date:' 'Expiry date:' 'Expire Date:' 'renewal date:' 'Expires:' 'validity:' 'Expiration Date :' 'Expiry :' 'expires at:' 'domain_datebilleduntil:' 'Data de expiração \/ Expiration Date \(dd\/mm\/yyyy\):' 'Fecha de expiración \(Expiration date\):' '\[Expires on\]' 'Record expires on' 'status: OK-UNTIL' 'renewal:' 'expires............:' 'expire-date:' 'Exp date:' 'Valid-date' 'Expires On:')
local toMatch=('expire:' 'Expiration Date:' 'expire on:' 'Expiry Date:' 'free-date' 'expires:' 'Expiration date:' 'Expiry date:' 'Expire Date:' 'renewal date:' 'Expires:' 'validity:' 'Expiration Date :' 'Expiry :' 'expires at:' 'domain_datebilleduntil:' 'Data de expiração \/ Expiration Date \(dd\/mm\/yyyy\):' 'Fecha de expiración \(Expiration date\):' '\[Expires on\]' 'Record expires on' 'status: OK-UNTIL' 'renewal:' 'expires............:' 'expire-date:' 'Exp date:' 'Valid-date' 'Expires On:' "Date d'expiration:")

for i in ${!toMatch[*]}
do
Expand Down Expand Up @@ -977,13 +977,13 @@ formatDate()
# Date in format: 20170102 // Month: jan
local regex25='[0-9]{8}$'
# Date in format: 02-Jan-2017
local regex26='[0-9]{2}-[A-Z]{1}[a-z]{2}-[0-9]{4}'
local regex26='[0-9]{2}-[A-Z]{1}[a-z]{2}-[0-9]{4}$'
# Date in format: 02.1.2017 // Month: jan
local regex27='[0-9]{2}\.[0-9]{1}\.[0-9]{4}'
# Date in format: 02 Jan 2017
local regex28='[0-9]\s[A-Z]{1}[a-z]{2}\s[0-9]{4}'

if [[ "${expirationDate}" =~ ${regex1} || "${expirationDate}" =~ ${regex11} || "${expirationDate}" =~ ${regex26} ]]
if [[ "${expirationDate}" =~ ${regex1} || "${expirationDate}" =~ ${regex26} ]]
then
# We split the date
local day=$(echo "${expirationDate}" | tr -cd '[[:digit:]]' | head -c2)
Expand All @@ -993,6 +993,18 @@ formatDate()
# We assign the expiration date
expirationDate=${day}'-'${month}'-'${year}

# We convert it to lower case
dateToLower
elif [[ "${expirationDate}" =~ ${regex11} ]]
then
# We split the date
local day=$(echo "${expirationDate}" | tr -cd '[[:digit:]]' | head -c2)
local year=$(echo "${expirationDate}" | tr -cd '[[:digit:]]' | head -c6 | tail -c4)
local month=$(echo "${expirationDate}" | tr -cd '[[:alpha:]]' | head -c3)

# We assign the expiration date
expirationDate=${day}'-'${month}'-'${year}

# We convert it to lower case
dateToLower
elif [[ "${expirationDate}" =~ ${regex2} || "${expirationDate}" =~ ${regex3} || "${expirationDate}" =~ ${regex10} || "${expirationDate}" =~ ${regex22} ]]
Expand Down

0 comments on commit 628a790

Please sign in to comment.