|
@@ -1,9 +1,8 @@
|
|
|
import { invariant } from 'foxact/invariant';
|
|
import { invariant } from 'foxact/invariant';
|
|
|
import createKeywordFilter from '../aho-corasick';
|
|
import createKeywordFilter from '../aho-corasick';
|
|
|
-import { buildParseDomainMap } from '../stable-sort-domain';
|
|
|
|
|
|
|
+import { buildParseDomainMap, sortDomains } from '../stable-sort-domain';
|
|
|
import { RuleOutput } from './base';
|
|
import { RuleOutput } from './base';
|
|
|
import type { SingboxSourceFormat } from '../singbox';
|
|
import type { SingboxSourceFormat } from '../singbox';
|
|
|
-import { appendArrayFromSet } from '../misc';
|
|
|
|
|
|
|
|
|
|
type Preprocessed = string[];
|
|
type Preprocessed = string[];
|
|
|
|
|
|
|
@@ -96,8 +95,15 @@ export class DomainsetOutput extends RuleOutput<Preprocessed> {
|
|
|
adguardhome(whitelist: Set<string | `.${string}`>): string[] {
|
|
adguardhome(whitelist: Set<string | `.${string}`>): string[] {
|
|
|
const results: string[] = [];
|
|
const results: string[] = [];
|
|
|
|
|
|
|
|
- // whitelist
|
|
|
|
|
- appendArrayFromSet(results, whitelist, i => (i[0] === '.' ? '@@||' + i.slice(1) + '^' : '@@|' + i + '^'));
|
|
|
|
|
|
|
+ const whitelistArray = sortDomains(Array.from(whitelist));
|
|
|
|
|
+ for (let i = 0, len = whitelistArray.length; i < len; i++) {
|
|
|
|
|
+ const domain = whitelistArray[i];
|
|
|
|
|
+ if (domain[0] === '.') {
|
|
|
|
|
+ results.push(`@@||${domain.slice(1)}^`);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ results.push(`@@|${domain}^`);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
for (let i = 0, len = this.$preprocessed.length; i < len; i++) {
|
|
for (let i = 0, len = this.$preprocessed.length; i < len; i++) {
|
|
|
const domain = this.$preprocessed[i];
|
|
const domain = this.$preprocessed[i];
|