diff --git a/package-lock.json b/package-lock.json index f24cf8d..e6d6c9a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "whoiser", - "version": "1.5.1", + "version": "1.5.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 159e7d1..5ab4686 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "whoiser", - "version": "1.5.1", + "version": "1.5.2", "description": "Whois info for TLDs, domains and IPs", "keywords": [ "whois", diff --git a/parsers.js b/parsers.js index 65d19bf..bad0476 100644 --- a/parsers.js +++ b/parsers.js @@ -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', @@ -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 = [ @@ -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))) { @@ -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()