diff --git a/app/http/endpoints/api/panel/validation.go b/app/http/endpoints/api/panel/validation.go index 1a1a3c2..56396f4 100644 --- a/app/http/endpoints/api/panel/validation.go +++ b/app/http/endpoints/api/panel/validation.go @@ -4,6 +4,10 @@ import ( "context" "errors" "fmt" + "regexp" + "strings" + "time" + "github.com/TicketsBot/GoPanel/app" "github.com/TicketsBot/GoPanel/app/http/validation" "github.com/TicketsBot/GoPanel/app/http/validation/defaults" @@ -15,9 +19,6 @@ import ( "github.com/rxdn/gdl/objects/channel" "github.com/rxdn/gdl/objects/guild" "github.com/rxdn/gdl/objects/interaction/component" - "regexp" - "strings" - "time" ) func ApplyPanelDefaults(data *panelBody) { @@ -171,7 +172,9 @@ var urlRegex = regexp.MustCompile(`^https?://([-a-zA-Z0-9@:%._+~#=]{1,256})\.[a- func validateNullableUrl(url *string) validation.ValidationFunc { return func() error { if url != nil && (len(*url) > 255 || !urlRegex.MatchString(*url)) { - return validation.NewInvalidInputError("Invalid URL") + if *url != "%avatar_url%" { + return validation.NewInvalidInputError("Invalid URL") + } } return nil diff --git a/utils/types/customembed.go b/utils/types/customembed.go index 93ed3e8..26e66f2 100644 --- a/utils/types/customembed.go +++ b/utils/types/customembed.go @@ -12,8 +12,8 @@ type CustomEmbed struct { Url *string `json:"url" validate:"omitempty,url,max=255"` Colour Colour `json:"colour" validate:"gte=0,lte=16777215"` Author Author `json:"author" validate:"dive"` - ImageUrl *string `json:"image_url" validate:"omitempty,url,max=255"` - ThumbnailUrl *string `json:"thumbnail_url" validate:"omitempty,url,max=255"` + ImageUrl *string `json:"image_url" validate:"omitempty,max=255"` + ThumbnailUrl *string `json:"thumbnail_url" validate:"omitempty,max=255"` Footer Footer `json:"footer" validate:"dive"` Timestamp *DateTimeLocal `json:"timestamp" validate:"omitempty"` Fields []Field `json:"fields" validate:"dive,max=25"`