mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 17:20:35 +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[] => {
|
||||
return hostname.split('.').reduce<string[]>((acc, token, index) => {
|
||||
if (index !== 0) {
|
||||
acc.push('.');
|
||||
if (index > 0) {
|
||||
acc.push('.', token);
|
||||
} else if (token.length > 0) {
|
||||
acc.push(token);
|
||||
}
|
||||
acc.push(token);
|
||||
return acc;
|
||||
}, []);
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user