Update Rules

This commit is contained in:
SukkaW
2021-11-29 00:46:48 +08:00
parent 6fade2cba1
commit 58ce1dafd0
6 changed files with 3411 additions and 127 deletions

View File

@@ -1,17 +1,17 @@
exports.dedupe = ({ fullSet, input }) => {
const output = new Set();
for (const domain of input) {
for (const domain2 of fullSet) {
for (const domainFromInput of input) {
for (const domainFromFullSet of fullSet) {
if (
domain2.startsWith('.')
&& domain2 !== domain
domainFromFullSet.startsWith('.')
&& domainFromFullSet !== domainFromInput
&& (
domain.endsWith(domain2)
|| `.${domain}` === domain2
domainFromInput.endsWith(domainFromFullSet)
|| `.${domainFromInput}` === domainFromFullSet
)
) {
output.add(domain);
output.add(domainFromInput);
break;
}
}
@@ -35,7 +35,7 @@ exports.whitelisted = ({ whiteList, input }) => {
return output;
};
exports.dedupeKeywords = ({ keywords, input }) => {
exports.dedupeKeywords = ({ keywords, suffixes, input }) => {
const output = new Set();
for (const domain of input) {
@@ -45,6 +45,12 @@ exports.dedupeKeywords = ({ keywords, input }) => {
break;
}
}
for (const suffix of suffixes) {
if (domain.endsWith(suffix)) {
output.add(domain);
break;
}
}
}
return output;