mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-08-27 14:22:20 +02:00
modify AppendUnique so it matches only the first two items.
This commit is contained in:
10
tags.go
10
tags.go
@@ -99,9 +99,15 @@ func (tags Tags) FilterOut(tagPrefix []string) Tags {
|
||||
return filtered
|
||||
}
|
||||
|
||||
// AppendUnique appends a tag if it doesn't exist yet, otherwise does nothing
|
||||
// AppendUnique appends a tag if it doesn't exist yet, otherwise does nothing.
|
||||
// the uniqueness comparison is done based only on the first 2 elements of the tag.
|
||||
func (tags Tags) AppendUnique(tag Tag) Tags {
|
||||
if tags.GetFirst(tag) == nil {
|
||||
n := len(tag)
|
||||
if n > 2 {
|
||||
n = 2
|
||||
}
|
||||
|
||||
if tags.GetFirst(tag[:n]) == nil {
|
||||
return append(tags, tag)
|
||||
} else {
|
||||
return tags
|
||||
|
Reference in New Issue
Block a user