Simplify some functions

This commit is contained in:
Jason Streifling 2025-01-24 22:59:20 +01:00
parent d8d0526a05
commit 089c573aed

View File

@ -90,11 +90,7 @@ func isValidMediaType(m string) bool {
}
typeParts := strings.Split(mediaType, "/")
if len(typeParts) != 2 || typeParts[0] == "" || typeParts[1] == "" {
return false
}
return true
return len(typeParts) == 2 && typeParts[0] != "" && typeParts[1] != ""
}
// isValidLanguageTag checks whether a LanguageTag is valid. It returns a bool.
@ -105,8 +101,7 @@ func isValidLanguageTag(languageTag string) bool {
// isValidAttribute checks whether an Attribute is valid. It returns a bool.
func isValidAttribute(attribute string) bool {
regex := regexp.MustCompile(`^[a-zA-Z0-9_]+="[^"]*"$`)
return regex.MatchString(attribute)
return regexp.MustCompile(`^[a-zA-Z0-9_]+="[^"]*"$`).MatchString(attribute)
}
// NewURN generates an new valid IRI based on a UUID. It returns an IRI.