Skip to content

Commit 5a55c67

Browse files
committed
nip10: fix.
1 parent bf0c4d4 commit 5a55c67

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

jsr.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nostr/tools",
3-
"version": "2.10.2",
3+
"version": "2.10.3",
44
"exports": {
55
".": "./index.ts",
66
"./core": "./core.ts",

nip10.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,26 @@ export function parse(event: Pick<Event, 'tags'>): {
108108

109109
// remove root and reply from mentions, inherit relay hints from authors if any
110110
;[result.reply, result.root].forEach(ref => {
111-
let idx = result.mentions.indexOf(ref!)
111+
if (!ref) return
112+
113+
let idx = result.mentions.indexOf(ref)
112114
if (idx !== -1) {
113115
result.mentions.splice(idx, 1)
114116
}
115-
if (ref!.author) {
116-
let author = result.profiles.find(p => p.pubkey === ref!.author)
117+
if (ref.author) {
118+
let author = result.profiles.find(p => p.pubkey === ref.author)
117119
if (author && author.relays) {
118-
if (!ref!.relays) {
119-
ref!.relays = []
120+
if (!ref.relays) {
121+
ref.relays = []
120122
}
121123
author.relays.forEach(url => {
122-
if (ref?.relays!?.indexOf(url) === -1) ref!.relays!.push(url)
124+
if (ref.relays!?.indexOf(url) === -1) ref.relays!.push(url)
123125
})
124-
author.relays = ref!.relays
126+
author.relays = ref.relays
125127
}
126128
}
127129
})
130+
128131
result.mentions.forEach(ref => {
129132
if (ref!.author) {
130133
let author = result.profiles.find(p => p.pubkey === ref.author)

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"type": "module",
33
"name": "nostr-tools",
4-
"version": "2.10.2",
4+
"version": "2.10.3",
55
"description": "Tools for making a Nostr client.",
66
"repository": {
77
"type": "git",

0 commit comments

Comments
 (0)