From 175ba651277b10c3de0b29f2b7840c6017586d73 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Sun, 30 Jun 2024 00:30:46 +0800 Subject: [PATCH] Fix: correct trie tokenizer behavior --- Build/lib/trie.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Build/lib/trie.ts b/Build/lib/trie.ts index abf73706..b7d0bc72 100644 --- a/Build/lib/trie.ts +++ b/Build/lib/trie.ts @@ -31,10 +31,11 @@ const createNode = (parent: TrieNode | null = null): TrieNode => { const hostnameToTokens = (hostname: string): string[] => { return hostname.split('.').reduce((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; }, []); };