Skip to content

Commit

Permalink
Fix issue with false passed to combineResults
Browse files Browse the repository at this point in the history
  • Loading branch information
MattIPv4 committed Feb 14, 2021
1 parent 7b9e9ba commit 4f9c20b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "web-whois",
"version": "0.0.3",
"version": "0.0.4",
"description": "Perform RDAP/WHOIS lookups over HTTP",
"main": "src/index.js",
"keywords": [],
Expand Down
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ const { consistentResultObj, consistentResult } = require('./util');
const combineResults = dataArr => {
const result = {};
for (const data of dataArr)
for (const key of data)
if (data[key] && !result[key]) result[key] = data[key];
for (const key in data)
if (Object.prototype.hasOwnProperty.call(data, key))
if (data[key] && !result[key]) result[key] = data[key];
return consistentResult(consistentResultObj(result));
};

Expand All @@ -31,5 +32,5 @@ module.exports = async (query, first = false) => {
if (cfwho && first) return cfwho;

// Combine the results (preferring RDAP, WHOIS, then cfwho)
return combineResults([rdap, whois, cfwho]);
return combineResults([rdap || {}, whois || {}, cfwho || {}]);
};

0 comments on commit 4f9c20b

Please sign in to comment.