This commit is contained in:
Michael Jerger 2024-01-13 16:22:49 +01:00
parent ca5eaa8c6b
commit 9a9ac33766
3 changed files with 6 additions and 6 deletions

View file

@ -178,7 +178,8 @@ func Test_PersonUnmarshalJSON(t *testing.T) {
PreferredUsername: ap.NaturalLanguageValues{
ap.LangRefValue{Ref: "en", Value: []byte("MaxMuster")},
},
}}
},
}
sut := new(ForgePerson)
err := sut.UnmarshalJSON([]byte(`{"type":"Person","preferredUsername":"MaxMuster"}`))
if err != nil {

View file

@ -62,19 +62,19 @@ func (node NodeInfoWellKnown) Validate() []string {
var result []string
result = append(result, validation.ValidateNotEmpty(node.Href, "Href")...)
parsedUrl, err := url.Parse(node.Href)
parsedURL, err := url.Parse(node.Href)
if err != nil {
result = append(result, err.Error())
return result
}
if parsedUrl.Host == "" {
if parsedURL.Host == "" {
result = append(result, "Href has to be absolute")
}
result = append(result, validation.ValidateOneOf(parsedUrl.Scheme, []any{"http", "https"})...)
result = append(result, validation.ValidateOneOf(parsedURL.Scheme, []any{"http", "https"})...)
if parsedUrl.RawQuery != "" {
if parsedURL.RawQuery != "" {
result = append(result, "Href may not contain query")
}

View file

@ -29,7 +29,6 @@ func Test_ValidateNotEmpty_ForTimestamp(t *testing.T) {
if res := ValidateNotEmpty(sut, "dummyField"); len(res) > 0 {
t.Errorf("sut should be valid but was %q", res)
}
}
func Test_ValidateMaxLen(t *testing.T) {