From 6782d0c847043e8c1f79b5f7ddefb04815dcb448 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Tue, 15 Oct 2024 18:44:02 +0200 Subject: [PATCH] Move hasAlternateDumplicateLinks from feed to link in order to also use it elsewhere --- feed.go | 19 ------------------- link.go | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/feed.go b/feed.go index d9df79e..f5c3f10 100644 --- a/feed.go +++ b/feed.go @@ -26,25 +26,6 @@ type Feed struct { Entries []*Entry `xml:"entry,omitempty"` } -// atom:feed elements MUST NOT contain more than one atom:link element with a -// rel attribute value of "alternate" that has the same combination of type and -// hreflang attribute values. -func hasAlternateDuplicateLinks(l []*Link) bool { - linkMap := make(map[string]bool) - - for _, link := range l { - if link.Rel == "alternate" { - key := fmt.Sprint(link.Type, "|", link.HrefLang) - if linkMap[key] { - return true - } - linkMap[key] = true - } - } - - return false -} - // NewFeed creates a new feed. func NewFeed(title string) (*Feed, error) { text, err := NewText("text", title) diff --git a/link.go b/link.go index cdfe4c7..df99e26 100644 --- a/link.go +++ b/link.go @@ -37,3 +37,22 @@ func (l *Link) Check() error { return nil } + +// atom:feed/entry elements MUST NOT contain more than one atom:link element +// with a rel attribute value of "alternate" that has the same combination of +// type and hreflang attribute values. +func hasAlternateDuplicateLinks(l []*Link) bool { + linkMap := make(map[string]bool) + + for _, link := range l { + if link.Rel == "alternate" { + key := fmt.Sprint(link.Type, "|", link.HrefLang) + if linkMap[key] { + return true + } + linkMap[key] = true + } + } + + return false +}