Content can also be empty
This commit is contained in:
parent
5a82f1799f
commit
e73b78ef30
@ -16,8 +16,10 @@ type Category struct {
|
|||||||
|
|
||||||
// NewCategory creates a new Category. It returns a *Category and an error.
|
// NewCategory creates a new Category. It returns a *Category and an error.
|
||||||
func NewCategory(term, content string) (*Category, error) {
|
func NewCategory(term, content string) (*Category, error) {
|
||||||
if !isValidXML(content) {
|
if content != "" {
|
||||||
return nil, fmt.Errorf("%v not valid XML", content)
|
if !isValidXML(content) {
|
||||||
|
return nil, fmt.Errorf("%v not valid XML", content)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Category{Term: term, Content: content}, nil
|
return &Category{Term: term, Content: content}, nil
|
||||||
|
6
link.go
6
link.go
@ -19,8 +19,10 @@ type Link struct {
|
|||||||
|
|
||||||
// NewLink creates a new Link. It returns a *Link and an error.
|
// NewLink creates a new Link. It returns a *Link and an error.
|
||||||
func NewLink(href, content string) (*Link, error) {
|
func NewLink(href, content string) (*Link, error) {
|
||||||
if !isValidXML(content) {
|
if content != "" {
|
||||||
return nil, fmt.Errorf("%v not valid XML", content)
|
if !isValidXML(content) {
|
||||||
|
return nil, fmt.Errorf("%v not valid XML", content)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Link{Href: IRI(href), Content: content}, nil
|
return &Link{Href: IRI(href), Content: content}, nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user