Skip to content

Commit

Permalink
nip10: fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Nov 13, 2024
1 parent bf0c4d4 commit 5a55c67
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion jsr.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nostr/tools",
"version": "2.10.2",
"version": "2.10.3",
"exports": {
".": "./index.ts",
"./core": "./core.ts",
Expand Down
17 changes: 10 additions & 7 deletions nip10.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,26 @@ export function parse(event: Pick<Event, 'tags'>): {

// remove root and reply from mentions, inherit relay hints from authors if any
;[result.reply, result.root].forEach(ref => {
let idx = result.mentions.indexOf(ref!)
if (!ref) return

let idx = result.mentions.indexOf(ref)
if (idx !== -1) {
result.mentions.splice(idx, 1)
}
if (ref!.author) {
let author = result.profiles.find(p => p.pubkey === ref!.author)
if (ref.author) {
let author = result.profiles.find(p => p.pubkey === ref.author)
if (author && author.relays) {
if (!ref!.relays) {
ref!.relays = []
if (!ref.relays) {
ref.relays = []
}
author.relays.forEach(url => {
if (ref?.relays!?.indexOf(url) === -1) ref!.relays!.push(url)
if (ref.relays!?.indexOf(url) === -1) ref.relays!.push(url)
})
author.relays = ref!.relays
author.relays = ref.relays
}
}
})

result.mentions.forEach(ref => {
if (ref!.author) {
let author = result.profiles.find(p => p.pubkey === ref.author)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "module",
"name": "nostr-tools",
"version": "2.10.2",
"version": "2.10.3",
"description": "Tools for making a Nostr client.",
"repository": {
"type": "git",
Expand Down

0 comments on commit 5a55c67

Please sign in to comment.