mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-13 01:30:37 +08:00
Fix: correct trie tokenizer behavior
This commit is contained in:
parent
f10495fe67
commit
175ba65127
@ -31,10 +31,11 @@ const createNode = (parent: TrieNode | null = null): TrieNode => {
|
|||||||
|
|
||||||
const hostnameToTokens = (hostname: string): string[] => {
|
const hostnameToTokens = (hostname: string): string[] => {
|
||||||
return hostname.split('.').reduce<string[]>((acc, token, index) => {
|
return hostname.split('.').reduce<string[]>((acc, token, index) => {
|
||||||
if (index !== 0) {
|
if (index > 0) {
|
||||||
acc.push('.');
|
acc.push('.', token);
|
||||||
}
|
} else if (token.length > 0) {
|
||||||
acc.push(token);
|
acc.push(token);
|
||||||
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, []);
|
}, []);
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user