Skip to content

Commit

Permalink
add len check
Browse files Browse the repository at this point in the history
  • Loading branch information
sebm253 committed Sep 21, 2024
1 parent 5b479cf commit 4530a98
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions discord/cdn_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,12 @@ func WithFormat(format FileFormat) CDNOpt {

func formatAssetURL(cdnRoute *CDNEndpoint, opts []CDNOpt, params ...any) string {
config := DefaultCDNConfig()
// use the first provided format in the route definition itself. if the user provides a different format, this will be overriden by the Apply function call below
// previously, the default format was png, which would cause issues for cdn endpoints like attachments and soundboard sounds, requiring custom "overrides"
config.Format = cdnRoute.Formats[0]

if len(cdnRoute.Formats) != 0 { // just in case someone fucks up
// use the first provided format in the route definition itself. if the user provides a different format, this will be overriden by the Apply function call below
// previously, the default format was png, which would cause issues for cdn endpoints like attachments and soundboard sounds, requiring custom "overrides"
config.Format = cdnRoute.Formats[0]
}
config.Apply(opts)

var lastStringParam string
Expand Down

0 comments on commit 4530a98

Please sign in to comment.