fix: normalize Unicode in local user search for special characters
Apply NFKD normalization to both indexed text and search queries so that stylized Unicode characters (e.g. 𝚋𝚊𝚝𝚜𝚒𝚚) are decomposed to their ASCII equivalents and can be matched by search. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3576a11595
commit
330152fd5c
1 changed files with 4 additions and 2 deletions
|
|
@ -1040,7 +1040,7 @@ class ClientService extends EventTarget {
|
|||
/** =========== Profile =========== */
|
||||
|
||||
async searchNpubsFromLocal(query: string, limit: number = 100) {
|
||||
const result = await this.userIndex.searchAsync(query, { limit })
|
||||
const result = await this.userIndex.searchAsync(query.normalize('NFKD'), { limit })
|
||||
return result.map((pubkey) => pubkeyToNpub(pubkey as string)).filter(Boolean) as string[]
|
||||
}
|
||||
|
||||
|
|
@ -1060,7 +1060,9 @@ class ClientService extends EventTarget {
|
|||
?.split('@')
|
||||
.map((s: string) => s.trim())
|
||||
.join(' ') ?? ''
|
||||
].join(' ')
|
||||
]
|
||||
.join(' ')
|
||||
.normalize('NFKD')
|
||||
if (!text) return
|
||||
|
||||
await this.userIndex.addAsync(profileEvent.pubkey, text)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue