Compare commits
4 Commits
v0.1.4
...
e0902d9ba4
Author | SHA1 | Date | |
---|---|---|---|
e0902d9ba4 | |||
434783165b | |||
46138d302b | |||
6b9d5be734 |
18
entry.go
18
entry.go
@ -34,13 +34,15 @@ type Entry struct {
|
|||||||
// the atom:entry contains an atom:source element that contains an atom:author
|
// the atom:entry contains an atom:source element that contains an atom:author
|
||||||
// element or, in an Atom Feed Document, the atom:feed element contains an
|
// element or, in an Atom Feed Document, the atom:feed element contains an
|
||||||
// atom:author element itself.
|
// atom:author element itself.
|
||||||
func (e *Entry) checkAuthors() error {
|
func (e *Entry) checkAuthors(authorInFeed bool) error {
|
||||||
if e.Authors == nil {
|
if e.Authors == nil {
|
||||||
if e.Source == nil {
|
if !authorInFeed {
|
||||||
return errors.New("no authors set in entry")
|
if e.Source == nil {
|
||||||
}
|
return errors.New("no authors set in entry")
|
||||||
if e.Source.Authors == nil {
|
}
|
||||||
return errors.New("no authors set in entry")
|
if e.Source.Authors == nil {
|
||||||
|
return errors.New("no authors set in entry")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for i, a := range e.Authors {
|
for i, a := range e.Authors {
|
||||||
@ -138,7 +140,7 @@ func (e *Entry) Check() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := e.checkAuthors(); err != nil {
|
if err := e.checkAuthors(true); err != nil {
|
||||||
return fmt.Errorf("entry %v: %v", e.ID.URI, err)
|
return fmt.Errorf("entry %v: %v", e.ID.URI, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +213,7 @@ func (e *Entry) Check() error {
|
|||||||
// is not an XML media type [RFC3023], does not begin with "text/", and
|
// is not an XML media type [RFC3023], does not begin with "text/", and
|
||||||
// does not end with "/xml" or "+xml".
|
// does not end with "/xml" or "+xml".
|
||||||
mediaType := e.Content.getType()
|
mediaType := e.Content.getType()
|
||||||
if !isXMLMediaType(mediaType) && !strings.HasPrefix(mediaType, "text/") {
|
if isValidMediaType(mediaType) && !isXMLMediaType(mediaType) && !strings.HasPrefix(mediaType, "text/") {
|
||||||
return fmt.Errorf("no summary element of entry %v but media type not xml", e.ID.URI)
|
return fmt.Errorf("no summary element of entry %v but media type not xml", e.ID.URI)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
feed.go
2
feed.go
@ -128,7 +128,7 @@ func (f *Feed) Check() error {
|
|||||||
// least one atom:author element.
|
// least one atom:author element.
|
||||||
if f.Authors == nil {
|
if f.Authors == nil {
|
||||||
for _, e := range f.Entries {
|
for _, e := range f.Entries {
|
||||||
if err := e.checkAuthors(); err != nil {
|
if err := e.checkAuthors(false); err != nil {
|
||||||
return fmt.Errorf("no authors set in feed %v: %v", f.ID.URI, err)
|
return fmt.Errorf("no authors set in feed %v: %v", f.ID.URI, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
18
link.go
18
link.go
@ -38,16 +38,22 @@ func (l *Link) Check() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(l.Rel, ":") || !isValidIRI(IRI(l.Rel)) {
|
if l.Rel != "" {
|
||||||
return fmt.Errorf("rel attribute %v of link %v not correctly formatted", l.Rel, l.Href)
|
if strings.Contains(l.Rel, ":") && !isValidIRI(IRI(l.Rel)) {
|
||||||
|
return fmt.Errorf("rel attribute %v of link %v not correctly formatted", l.Rel, l.Href)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isValidMediaType(string(l.Type)) {
|
if l.Type != "" {
|
||||||
return fmt.Errorf("type attribute %v of link %v invalid media type", l.Type, l.Href)
|
if !isValidMediaType(string(l.Type)) {
|
||||||
|
return fmt.Errorf("type attribute %v of link %v invalid media type", l.Type, l.Href)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !isValidLanguageTag(l.HrefLang) {
|
if l.HrefLang != "" {
|
||||||
return fmt.Errorf("hreflang attribute %v of link %v invalid language tag", l.Type, l.HrefLang)
|
if !isValidLanguageTag(l.HrefLang) {
|
||||||
|
return fmt.Errorf("hreflang attribute %v of link %v invalid language tag", l.Type, l.HrefLang)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if l.Content == nil {
|
if l.Content == nil {
|
||||||
|
Reference in New Issue
Block a user