Fix Tags.normalize

This commit is contained in:
Jon Staab
2023-11-16 04:55:20 -08:00
parent de186dfd7b
commit c9d3cd910b
2 changed files with 5 additions and 2 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "paravel", "name": "paravel",
"version": "0.4.5", "version": "0.4.6",
"description": "Yet another toolkit for nostr", "description": "Yet another toolkit for nostr",
"author": "hodlbod", "author": "hodlbod",
"license": "MIT", "license": "MIT",
+4 -1
View File
@@ -180,13 +180,16 @@ export class Tags extends Fluent<string[]> {
// Support the deprecated version where tags are not marked as replies // Support the deprecated version where tags are not marked as replies
normalize() { normalize() {
const tags = this.type(["a", "e"]) let tags = this.type(["a", "e"])
// If we have a mark, we're not using the legacy format // If we have a mark, we're not using the legacy format
if (tags.any(t => t.length === 4 && ["reply", "root", "mention"].includes(last(t)))) { if (tags.any(t => t.length === 4 && ["reply", "root", "mention"].includes(last(t)))) {
return this return this
} }
// Legacy only supports e tags
tags = tags.type("e")
const reply = tags.values().last() const reply = tags.values().last()
const root = tags.count() > 1 ? tags.values().first() : null const root = tags.count() > 1 ? tags.values().first() : null