Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion package-lock.json

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

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
"prettier": "^2.0.4"
},
"dependencies": {
"punycode": "^2.1.1"
"punycode": "^2.1.1",
"undici": "^6.19.7"
},
"engines" : {
"node" : ">=15.0.0"
"engines": {
"node": ">=15.0.0"
}
}
19 changes: 9 additions & 10 deletions src/parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ const parseDomainWhois = (domain, whois, ignorePrivacy) => {
status: 'Domain Status',
state: 'Domain Status', // found in .ru
'registration status': 'Domain Status',
'eppstatus': 'Domain Status', // found in .fr
eppstatus: 'Domain Status', // found in .fr
'sponsoring registrar iana id': 'Registrar IANA ID',
organisation: 'Registrar',
registrar: 'Registrar',
Expand Down Expand Up @@ -558,8 +558,8 @@ const handleJpLines = (lines) => {

/**
* Normalize WHOIS data for .fr ccTld, make it look more like gTLDs
*
* @param {string[]} lines
*
* @param {string[]} lines
* @returns
*/
function handleDotFr(lines) {
Expand All @@ -568,26 +568,26 @@ function handleDotFr(lines) {
const finalLines = []

// split data in groups
lines.forEach(line => {
lines.forEach((line) => {
if (line.startsWith('%')) {
finalLines.push(line)
} else if (!line.trim().length && group.length) {
// start new group
groups.push(group)
group = []
} else if (line.trim().length && !line.startsWith('source')) {
group.push(splitStringBy(line, line.indexOf(':')).map(str => str.trim()))
group.push(splitStringBy(line, line.indexOf(':')).map((str) => str.trim()))
}
})

if (group.length) {
groups.push(group)
}

groups.forEach(gr => {
groups.forEach((gr) => {
if (gr[0][0] === 'domain') {
// group with domain info
gr.forEach(line => {
gr.forEach((line) => {
if (line[0] !== 'status') {
finalLines.push(line.join(': '))
}
Expand All @@ -603,7 +603,7 @@ function handleDotFr(lines) {
})
} else if (gr[0][0] === 'nic-hdl') {
let contactType = ''
const contactTypeLine = finalLines.find(line => line.includes(gr[0][1]))
const contactTypeLine = finalLines.find((line) => line.includes(gr[0][1]))

if (contactTypeLine.startsWith('admin-c')) {
contactType = 'admin'
Expand All @@ -622,11 +622,10 @@ function handleDotFr(lines) {
}
})
} else {
gr.forEach(line => {
gr.forEach((line) => {
finalLines.push(line.join(': '))
})
}

})

return finalLines
Expand Down
22 changes: 10 additions & 12 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
const punycode = require('punycode/')
const https = require('https')
const { request } = require('undici')

const splitStringBy = (string, by) => [string.slice(0, by), string.slice(by + 1)]

const requestGetBody = (url) => {
return new Promise((resolve, reject) => {
https
.get(url, (resp) => {
let data = ''
resp.on('data', (chunk) => (data += chunk))
resp.on('end', () => resolve(data))
resp.on('error', reject)
})
.on('error', reject)
})
const requestGetBody = async (url) => {
try {
const { body } = await request(url)
const data = await body.text()
return data
} catch (error) {
throw error
}
}

const isTld = (tld) => {
Expand Down