Browse Source

Fix dedupe

SukkaW 2 years ago
parent
commit
1f8786c229
1 changed files with 17 additions and 9 deletions
  1. 17 9
      Build/worker/build-reject-domainset-worker.js

+ 17 - 9
Build/worker/build-reject-domainset-worker.js

@@ -5,6 +5,8 @@ const Piscina = require('piscina');
 const fullsetDomainStartsWithADot = Piscina.workerData
 const fullsetDomainStartsWithADot = Piscina.workerData
 const totalLen = fullsetDomainStartsWithADot.length;
 const totalLen = fullsetDomainStartsWithADot.length;
 
 
+const DOT = '.';
+
 // const log = isCI ? () => { } : console.log.bind(console);
 // const log = isCI ? () => { } : console.log.bind(console);
 /**
 /**
  * @param {{ chunk: string[] }} param0
  * @param {{ chunk: string[] }} param0
@@ -25,17 +27,23 @@ module.exports = ({ chunk }) => {
       const domainFromFullSetLen = domainStartsWithADotAndFromFullSet.length;
       const domainFromFullSetLen = domainStartsWithADotAndFromFullSet.length;
 
 
       if (domainFromInputLen < domainFromFullSetLen) {
       if (domainFromInputLen < domainFromFullSetLen) {
-        if (domainFromInputLen + 1 === domainFromFullSetLen) {
-          // !domainFromInput.starsWith('.') && `.${domainFromInput}` === domainFromFullSet
-          if (domainFromInputChunk.charCodeAt(0) !== 46 && domainFromInputChunk.endsWith(domainStartsWithADotAndFromFullSet)) {
-            outputToBeRemoved[i] = 1;
-            // log(domainFromInputChunk, domainStartsWithADotAndFromFullSet)
-            break;
-          }
-        } else {
+        if (domainFromInputLen + 1 !== domainFromFullSetLen) {
+          break;
+        }
+
+        // !domainFromInput.starsWith('.') && `.${domainFromInput}` === domainFromFullSet
+        if (
+          domainFromInputChunk[0] !== DOT
+          && domainStartsWithADotAndFromFullSet.endsWith(domainFromInputChunk)
+        ) {
+          outputToBeRemoved[i] = 1;
+          // log(domainFromInputChunk, domainStartsWithADotAndFromFullSet)
           break;
           break;
         }
         }
-      } else if (domainFromInputLen > domainFromFullSetLen && domainFromInputChunk.endsWith(domainStartsWithADotAndFromFullSet)) {
+      } else if (
+        domainFromInputLen > domainFromFullSetLen
+        && domainFromInputChunk.endsWith(domainStartsWithADotAndFromFullSet)
+      ) {
         outputToBeRemoved[i] = 1;
         outputToBeRemoved[i] = 1;
         // log(domainFromInputChunk, domainStartsWithADotAndFromFullSet)
         // log(domainFromInputChunk, domainStartsWithADotAndFromFullSet)
         break;
         break;