Get rid of checks when creating constructs. Check should handle this.

This commit is contained in:
2024-10-19 14:12:51 +02:00
parent 960889f9e7
commit 57db4178d0
21 changed files with 143 additions and 345 deletions

View File

@@ -14,23 +14,10 @@ type OutOfLineContent struct {
}
// newOutOfLineContent creates a new OutOfLineContent. It returns a
// *OutOfLineContent and an error.
func newOutOfLineContent(mediaType string, content any) (*OutOfLineContent, error) {
if !isValidMediaType(mediaType) {
return nil, fmt.Errorf("error creating new out of line content: media type %v invalid", mediaType)
}
// *OutOfLineContent.
func newOutOfLineContent(mediaType, src string) *OutOfLineContent {
mediaType, _, _ = mime.ParseMediaType(mediaType)
iri, ok := content.(string)
if !ok {
return nil, fmt.Errorf("content type %T incompatible with out of line content", content)
}
if !isValidIRI(iri) {
return nil, fmt.Errorf("content %v not a valid uri", iri)
}
return &OutOfLineContent{Type: mediaType, SRC: iri}, nil
return &OutOfLineContent{Type: mediaType, SRC: src}
}
// isContent checks whether the OutOfLineContent is a Content. It returns a