Skip to content

Commit

Permalink
Updated - remove redacted data, merge more domain whois labels
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiIgna committed Nov 4, 2019
1 parent e594dcd commit 691eb4a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "whoiser",
"version": "1.5.1",
"version": "1.5.2",
"description": "Whois info for TLDs, domains and IPs",
"keywords": [
"whois",
Expand Down
16 changes: 13 additions & 3 deletions parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ const parseSimpleWhois = whois => {


const parseDomainWhois = whois => {
const noData = ['-', 'data protected, not disclosed', 'data redacted', 'redacted for privacy']
const renameLabels = {
'domain name': 'Domain Name',
'domain': 'Domain Name',
Expand All @@ -138,12 +139,13 @@ const parseDomainWhois = whois => {
'registrar registration expiration date': 'Expiry Date',
'registry expiry date': 'Expiry Date',
'expires on': 'Expiry Date',
'expires': 'Expiry Date',
'expiration time': 'Expiry Date',
'expire date': 'Expiry Date',
'paid-till': 'Expiry Date',
'expiry date': 'Expiry Date',
'registrant': 'Registrant Name',
'Registrant Contact Email': 'Registrant Email'
'registrant Contact Email': 'registrant Email'
}
const ignoreLabels = ['note', 'notes', 'please note', 'important', 'notice', 'terms of use', 'web-based whois', 'https', 'to', 'registration service provider']
const ignoreTexts = [
Expand Down Expand Up @@ -197,10 +199,16 @@ const parseDomainWhois = whois => {
if ((line.includes(': ') || line.endsWith(':')) && !line.startsWith('%') && !line.startsWith(';')) {
let [label, value] = splitStringBy(line, line.indexOf(':')).map(info => info.trim())

// rename labels to more common format
if (renameLabels[label.toLowerCase()]) {
label = renameLabels[label.toLowerCase()]
}

// remove redacted data
if (noData.includes(value.toLowerCase())) {
value = ''
}

if (data[label] && Array.isArray(data[label])) {
data[label].push(value)
} else if (!ignoreLabels.includes(label.toLowerCase()) && !ignoreTexts.some(text => label.toLowerCase().includes(text))) {
Expand All @@ -215,8 +223,10 @@ const parseDomainWhois = whois => {
})

// remove invalid Name Servers (not valid hostname)
data['Name Server'] = data['Name Server'].map(nameServer => nameServer.split(' ')[0]).filter(isDomain)
data['Domain Status'] = data['Domain Status'].filter(status => Boolean(status))
data['Name Server'] = data['Name Server'].map(nameServer => nameServer.split(' ')).flat().filter(isDomain)

// filter out empty status lines
data['Domain Status'] = data['Domain Status'].filter(Boolean)

// remove multiple empty lines
text = text.join("\n").trim()
Expand Down

0 comments on commit 691eb4a

Please sign in to comment.