Tags.GetD()

This commit is contained in:
fiatjaf 2023-12-29 15:58:25 -03:00
parent 8b1839bfc1
commit 45bdd193c5
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1

10
tags.go
View File

@ -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 {