From eb1eb8c7f14dd3feb9a8372a2129839859d40d1a Mon Sep 17 00:00:00 2001 From: mrrfv Date: Thu, 7 Sep 2023 20:52:04 +0200 Subject: [PATCH] Show a count of duplicate domains instead of listing all --- cf_list_create.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cf_list_create.js b/cf_list_create.js index dd77c19..ee6dad4 100644 --- a/cf_list_create.js +++ b/cf_list_create.js @@ -74,6 +74,7 @@ fs.readFile('input.csv', 'utf8', async (err, data) => { }); // Check for duplicates in domains array + let duplicateDomainCount = 0; let uniqueDomains = []; let seen = new Set(); // Use a set to store seen values for (let domain of domains) { @@ -81,9 +82,10 @@ fs.readFile('input.csv', 'utf8', async (err, data) => { seen.add(domain); // Add it to the set uniqueDomains.push(domain); // Push the domain to the uniqueDomains array } else { // If the domain is in the set - console.warn(`Duplicate domain found: ${domain} - removing`); // Log the duplicate domain + duplicateDomainCount++; // Increment the duplicateDomainCount } } + if (duplicateDomainCount > 0) console.warn(`Found ${duplicateDomainCount} duplicate domains in input.csv - removing`); // Replace domains array with uniqueDomains array domains = uniqueDomains;