Add needed checks for link if attributes are empty
This commit is contained in:
parent
46138d302b
commit
434783165b
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 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user