From e73b78ef3080edbab31c8c2a46c585684ab88e52 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Thu, 17 Oct 2024 18:40:52 +0200 Subject: [PATCH] Content can also be empty --- category.go | 6 ++++-- link.go | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/category.go b/category.go index 5600ac6..34febdc 100644 --- a/category.go +++ b/category.go @@ -16,8 +16,10 @@ type Category struct { // NewCategory creates a new Category. It returns a *Category and an error. func NewCategory(term, content string) (*Category, error) { - if !isValidXML(content) { - return nil, fmt.Errorf("%v not valid XML", content) + if content != "" { + if !isValidXML(content) { + return nil, fmt.Errorf("%v not valid XML", content) + } } return &Category{Term: term, Content: content}, nil diff --git a/link.go b/link.go index f132f99..9c0d92d 100644 --- a/link.go +++ b/link.go @@ -19,8 +19,10 @@ type Link struct { // NewLink creates a new Link. It returns a *Link and an error. func NewLink(href, content string) (*Link, error) { - if !isValidXML(content) { - return nil, fmt.Errorf("%v not valid XML", content) + if content != "" { + if !isValidXML(content) { + return nil, fmt.Errorf("%v not valid XML", content) + } } return &Link{Href: IRI(href), Content: content}, nil