mirror of
https://github.com/SukkaW/Surge.git
synced 2026-02-03 12:31:54 +08:00
Chore: update source deduping tool
This commit is contained in:
@@ -186,10 +186,44 @@ abstract class Triebase<Meta = unknown> {
|
||||
public contains(suffix: string, includeAllSubdomain = suffix[0] === '.'): boolean {
|
||||
const hostnameFromIndex = suffix[0] === '.' ? 1 : 0;
|
||||
|
||||
const res = this.walkIntoLeafWithSuffix(suffix, hostnameFromIndex);
|
||||
if (!res) return false;
|
||||
if (includeAllSubdomain) return getBit(res.node[0], INCLUDE_ALL_SUBDOMAIN);
|
||||
return true;
|
||||
let node: TrieNode = this.$root;
|
||||
// let parent: TrieNode = node;
|
||||
|
||||
let child: Map<string, TrieNode<Meta>> = node[2];
|
||||
|
||||
let result = false;
|
||||
|
||||
const onToken = (token: string) => {
|
||||
// if (token === '') {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// parent = node;
|
||||
|
||||
child = node[2];
|
||||
|
||||
if (child.has(token)) {
|
||||
node = child.get(token)!;
|
||||
} else {
|
||||
if (getBit(node[0], INCLUDE_ALL_SUBDOMAIN)) {
|
||||
result = true;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
if (walkHostnameTokens(suffix, onToken, hostnameFromIndex) === null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (includeAllSubdomain) return getBit(node[0], INCLUDE_ALL_SUBDOMAIN);
|
||||
return getBit(node[0], START);
|
||||
|
||||
// if (res === null) return false;
|
||||
// if (includeAllSubdomain) return getBit(res.node[0], INCLUDE_ALL_SUBDOMAIN);
|
||||
// return true;
|
||||
};
|
||||
|
||||
private static bfsResults: [node: TrieNode | null, suffix: string[]] = [null, []];
|
||||
|
||||
Reference in New Issue
Block a user