From 811205ccc24ddcca794f10d41b229ba81f67610c Mon Sep 17 00:00:00 2001 From: Viet Huynh Date: Tue, 12 Sep 2023 17:32:05 +0700 Subject: [PATCH] trim before processing domain --- cf_list_create.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cf_list_create.js b/cf_list_create.js index 28d451a..ac9d951 100644 --- a/cf_list_create.js +++ b/cf_list_create.js @@ -24,9 +24,13 @@ let duplicateDomainCount = 0; // Read allowlist console.log(`Processing ${allowlistFilename}`); await readFile(resolve(allowlistFilename), (line) => { - if (isComment(line)) return; + const _line = line.trim(); - const domain = normalizeDomain(line, true); + if (!_line) return; + + if (isComment(_line)) return; + + const domain = normalizeDomain(_line, true); if (!isValidDomain(domain)) return; @@ -40,9 +44,13 @@ await readFile(resolve(blocklistFilename), (line, rl) => { return; } - if (isComment(line)) return; + const _line = line.trim(); - const domain = normalizeDomain(line); + if (!_line) return; + + if (isComment(_line)) return; + + const domain = normalizeDomain(_line); if (!isValidDomain(domain)) return;