mirror of
https://github.com/SukkaW/Surge.git
synced 2026-02-02 20:11:54 +08:00
Fix Reject Process
This commit is contained in:
18
Build/lib/parse-filter.test.ts
Normal file
18
Build/lib/parse-filter.test.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { describe, it } from 'mocha';
|
||||
|
||||
import { processFilterRules } from './parse-filter';
|
||||
import { createCacheKey } from './cache-filesystem';
|
||||
import { createSpan } from '../trace';
|
||||
|
||||
const cacheKey = createCacheKey(__filename);
|
||||
|
||||
describe('processFilterRules', () => {
|
||||
it('https://filters.adtidy.org/extension/ublock/filters/18_optimized.txt', () => {
|
||||
console.log(processFilterRules(
|
||||
createSpan('noop'),
|
||||
cacheKey('https://filters.adtidy.org/extension/ublock/filters/18_optimized.txt'),
|
||||
[],
|
||||
7_200_000
|
||||
));
|
||||
});
|
||||
});
|
||||
@@ -14,14 +14,25 @@ import { looseTldtsOpt } from '../constants/loose-tldts-opt';
|
||||
|
||||
const DEBUG_DOMAIN_TO_FIND: string | null = null; // example.com | null
|
||||
let foundDebugDomain = false;
|
||||
const temporaryBypass = true;
|
||||
const temporaryBypass = typeof DEBUG_DOMAIN_TO_FIND === 'string';
|
||||
|
||||
const domainListLineCb = (l: string, set: string[], includeAllSubDomain: boolean, meta: string) => {
|
||||
let line = processLine(l);
|
||||
if (!line) return;
|
||||
line = line.toLowerCase();
|
||||
|
||||
line = normalizeDomain(line);
|
||||
if (!line) return;
|
||||
const domain = normalizeDomain(line);
|
||||
if (!domain) return;
|
||||
if (domain !== line) {
|
||||
console.log(
|
||||
picocolors.red('[process domain list]'),
|
||||
picocolors.gray(`line: ${line}`),
|
||||
picocolors.gray(`domain: ${domain}`),
|
||||
picocolors.gray(meta)
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (DEBUG_DOMAIN_TO_FIND && line.includes(DEBUG_DOMAIN_TO_FIND)) {
|
||||
console.warn(picocolors.red(meta), '(black)', line.replaceAll(DEBUG_DOMAIN_TO_FIND, picocolors.bold(DEBUG_DOMAIN_TO_FIND)));
|
||||
|
||||
Reference in New Issue
Block a user