Skip to content

Commit

Permalink
Tags.GetD()
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Dec 29, 2023
1 parent 781aecc commit 5414f09
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ func (tag Tag) Relay() string {

type Tags []Tag

// GetD gets the first "d" tag (for parameterized replaceable events) value or ""
func (tags Tags) GetD() string {
for _, v := range tags {
if v.StartsWith([]string{"d", ""}) {
return v[1]
}
}
return ""
}

// GetFirst gets the first tag in tags that matches the prefix, see [Tag.StartsWith]
func (tags Tags) GetFirst(tagPrefix []string) *Tag {
for _, v := range tags {
Expand Down

0 comments on commit 5414f09

Please sign in to comment.