diff --git a/link.go b/link.go index 3b83214..e369703 100644 --- a/link.go +++ b/link.go @@ -38,16 +38,22 @@ func (l *Link) Check() error { } } - 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.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 !isValidMediaType(string(l.Type)) { - return fmt.Errorf("type attribute %v of link %v invalid media type", l.Type, 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 !isValidLanguageTag(l.HrefLang) { - return fmt.Errorf("hreflang attribute %v of link %v invalid language tag", l.Type, l.HrefLang) + 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 {