Add needed checks for link if attributes are empty
This commit is contained in:
parent
46138d302b
commit
434783165b
6
link.go
6
link.go
@ -38,17 +38,23 @@ func (l *Link) Check() error {
|
||||
}
|
||||
}
|
||||
|
||||
if l.Rel != "" {
|
||||
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 l.Type != "" {
|
||||
if !isValidMediaType(string(l.Type)) {
|
||||
return fmt.Errorf("type attribute %v of link %v invalid media type", l.Type, l.Href)
|
||||
}
|
||||
}
|
||||
|
||||
if 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 {
|
||||
return fmt.Errorf("no content element of link %v", l.Href)
|
||||
|
Loading…
x
Reference in New Issue
Block a user