2024-10-13 17:19:40 +02:00
|
|
|
package atomfeed
|
|
|
|
|
2024-10-16 18:33:23 +02:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
|
|
|
)
|
2024-10-13 17:19:40 +02:00
|
|
|
|
|
|
|
type Logo struct {
|
|
|
|
*CommonAttributes
|
2024-10-16 17:33:25 +02:00
|
|
|
URI IRI `xml:"uri"`
|
2024-10-13 17:19:40 +02:00
|
|
|
}
|
|
|
|
|
2024-10-16 19:59:28 +02:00
|
|
|
// NewLogo creates a new Logo. It returns a *Logo.
|
2024-10-16 18:33:23 +02:00
|
|
|
func NewLogo() *Logo {
|
|
|
|
return &Logo{URI: IRI(fmt.Sprint("urn:uuid:", uuid.New()))}
|
|
|
|
}
|
|
|
|
|
2024-10-16 19:59:28 +02:00
|
|
|
// Check checks the Logo for incompatibilities with RFC4287. It returns an
|
|
|
|
// error.
|
2024-10-13 17:19:40 +02:00
|
|
|
func (l *Logo) Check() error {
|
|
|
|
if l.URI == "" {
|
|
|
|
return errors.New("uri element of logo empty")
|
2024-10-16 18:33:23 +02:00
|
|
|
} else {
|
|
|
|
if !isValidIRI(l.URI) {
|
|
|
|
return fmt.Errorf("uri element %v of logo not correctly formatted", l.URI)
|
|
|
|
}
|
2024-10-13 17:19:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|