25 lines
858 B
Go
25 lines
858 B
Go
// Package resourceview contains the stable client-facing projection rules for wallet resources.
|
|
package resourceview
|
|
|
|
import (
|
|
"encoding/json"
|
|
"strings"
|
|
)
|
|
|
|
// FormatFromMetadata returns only an explicitly configured renderer identifier. format is the
|
|
// current contract and animation_format remains a legacy fallback; URL suffixes are intentionally
|
|
// never inspected because signed/CDN URLs are not a trustworthy media-format fact.
|
|
func FormatFromMetadata(raw string) string {
|
|
var metadata struct {
|
|
Format string `json:"format"`
|
|
AnimationFormat string `json:"animation_format"`
|
|
}
|
|
if json.Unmarshal([]byte(strings.TrimSpace(raw)), &metadata) != nil {
|
|
return ""
|
|
}
|
|
if format := strings.ToLower(strings.TrimSpace(metadata.Format)); format != "" {
|
|
return format
|
|
}
|
|
return strings.ToLower(strings.TrimSpace(metadata.AnimationFormat))
|
|
}
|