build-reject-domainset-worker.js 994 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. exports.dedupe = ({ fullSet, input }) => {
  2. const output = new Set();
  3. for (const domain of input) {
  4. for (const domain2 of fullSet) {
  5. if (
  6. domain2.startsWith('.')
  7. && domain2 !== domain
  8. && (
  9. domain.endsWith(domain2)
  10. || `.${domain}` === domain2
  11. )
  12. ) {
  13. output.add(domain);
  14. break;
  15. }
  16. }
  17. }
  18. return output;
  19. };
  20. exports.whitelisted = ({ whiteList, input }) => {
  21. const output = new Set();
  22. for (const domain of input) {
  23. for (const white of whiteList) {
  24. if (domain.includes(white) || white.includes(domain)) {
  25. output.add(domain);
  26. break;
  27. }
  28. }
  29. }
  30. return output;
  31. };
  32. exports.dedupeKeywords = ({ keywords, input }) => {
  33. const output = new Set();
  34. for (const domain of input) {
  35. for (const keyword of keywords) {
  36. if (domain.includes(keyword) || keyword.includes(domain)) {
  37. output.add(domain);
  38. break;
  39. }
  40. }
  41. }
  42. return output;
  43. }