Compare commits

..

No commits in common. "f6bbc2fa6f72dc57c4b73239925b040a4b2a602e" and "f2c6fce7c90eb86ce8101d3f9e04e55ae80d056d" have entirely different histories.

2 changed files with 47 additions and 43 deletions

View File

@ -43,16 +43,6 @@ func (e *Entry) checkAuthors() error {
return nil
}
func alternateRelExists(l []*Link) bool {
for _, link := range l {
if link.Rel == "alternate" {
return true
}
}
return false
}
func (e *Entry) AddExtension(name string, value any) {
e.Extensions = append(e.Extensions, &ExtensionElement{XMLName: xml.Name{Local: name}, Value: value})
}
@ -70,9 +60,11 @@ func (e *Entry) Check() error {
return fmt.Errorf("entry %v: %v", e.ID.URI, err)
}
for i, c := range e.Categories {
if err := c.Check(); err != nil {
return fmt.Errorf("category element %v of entry %v: %v", i, e.ID.URI, err)
if e.Categories != nil {
for i, c := range e.Categories {
if err := c.Check(); err != nil {
return fmt.Errorf("category element %v of entry %v: %v", i, e.ID.URI, err)
}
}
}
@ -80,21 +72,21 @@ func (e *Entry) Check() error {
if err := (*e.Content).Check(); err != nil {
return fmt.Errorf("content element of entry %v: %v", e.ID.URI, err)
}
} else {
if !alternateRelExists(e.Links) {
return errors.New("no content element of entry %v and no link element with rel \"alternate\"")
}
if e.Contributors != nil {
for i, c := range e.Contributors {
if err := c.Check(); err != nil {
return fmt.Errorf("contributor element %v of entry %v: %v", i, e.ID.URI, err)
}
}
}
for i, c := range e.Contributors {
if err := c.Check(); err != nil {
return fmt.Errorf("contributor element %v of entry %v: %v", i, e.ID.URI, err)
}
}
for i, l := range e.Links {
if err := l.Check(); err != nil {
return fmt.Errorf("link element %v of entry %v: %v", i, e.ID.URI, err)
if e.Links != nil {
for i, l := range e.Links {
if err := l.Check(); err != nil {
return fmt.Errorf("link element %v of entry %v: %v", i, e.ID.URI, err)
}
}
}
@ -138,9 +130,11 @@ func (e *Entry) Check() error {
}
}
for i, x := range e.Extensions {
if err := x.Check(); err != nil {
return fmt.Errorf("extension element %v of entry %v: %v", i, e.ID.URI, err)
if e.Extensions != nil {
for i, x := range e.Extensions {
if err := x.Check(); err != nil {
return fmt.Errorf("extension element %v of entry %v: %v", i, e.ID.URI, err)
}
}
}

40
feed.go
View File

@ -156,15 +156,19 @@ func (f *Feed) Check() error {
}
}
for i, c := range f.Categories {
if err := c.Check(); err != nil {
return fmt.Errorf("category element %v of feed %v: %v", i, f.ID.URI, err)
if f.Categories != nil {
for i, c := range f.Categories {
if err := c.Check(); err != nil {
return fmt.Errorf("category element %v of feed %v: %v", i, f.ID.URI, err)
}
}
}
for i, c := range f.Contributors {
if err := c.Check(); err != nil {
return fmt.Errorf("contributor element %v of feed %v: %v", i, f.ID.URI, err)
if f.Contributors != nil {
for i, c := range f.Contributors {
if err := c.Check(); err != nil {
return fmt.Errorf("contributor element %v of feed %v: %v", i, f.ID.URI, err)
}
}
}
@ -180,9 +184,11 @@ func (f *Feed) Check() error {
}
}
for i, l := range f.Links {
if err := l.Check(); err != nil {
return fmt.Errorf("link element %v of feed %v: %v", i, f.ID.URI, err)
if f.Links != nil {
for i, l := range f.Links {
if err := l.Check(); err != nil {
return fmt.Errorf("link element %v of feed %v: %v", i, f.ID.URI, err)
}
}
}
if hasAlternateDuplicateLinks(f.Links) {
@ -223,15 +229,19 @@ func (f *Feed) Check() error {
}
}
for i, x := range f.Extensions {
if err := x.Check(); err != nil {
return fmt.Errorf("extension element %v of feed %v: %v", i, f.ID.URI, err)
if f.Extensions != nil {
for i, x := range f.Extensions {
if err := x.Check(); err != nil {
return fmt.Errorf("extension element %v of feed %v: %v", i, f.ID.URI, err)
}
}
}
for i, n := range f.Entries {
if err := n.Check(); err != nil {
return fmt.Errorf("entry element %v of feed %v: %v", i, f.ID.URI, err)
if f.Entries != nil {
for i, n := range f.Entries {
if err := n.Check(); err != nil {
return fmt.Errorf("entry element %v of feed %v: %v", i, f.ID.URI, err)
}
}
}