Check uris before applying them

This commit is contained in:
2024-10-17 19:28:09 +02:00
parent cb61d90cae
commit 6117876a59
5 changed files with 32 additions and 10 deletions

View File

@@ -11,8 +11,12 @@ type Logo struct {
}
// NewLogo creates a new Logo. It returns a *Logo.
func NewLogo(uri string) *Logo {
return &Logo{URI: IRI(uri)}
func NewLogo(uri IRI) (*Logo, error) {
if !isValidIRI(uri) {
return nil, fmt.Errorf("uri %v not correctly formatted", uri)
}
return &Logo{URI: uri}, nil
}
// Check checks the Logo for incompatibilities with RFC4287. It returns an