File tree Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,14 @@ func NewKey(m map[string]interface{}) (k Key, err errors.ICCError) {
5959 if index != 0 {
6060 keyExists = false
6161 }
62+ } else {
63+ // Get asset type from @key
64+ parts := strings .Split (k ["@key" ].(string ), ":" )
65+ if len (parts ) < 2 {
66+ err = errors .NewCCError ("cannot determine asset type from key" , 400 )
67+ return
68+ }
69+ k ["@assetType" ] = parts [0 ]
6270 }
6371 }
6472
@@ -72,18 +80,6 @@ func NewKey(m map[string]interface{}) (k Key, err errors.ICCError) {
7280 k ["@key" ] = keyStr
7381 }
7482
75- // Validate if @assetType exists
76- _ , typeExists := k ["@assetType" ].(string )
77- if ! typeExists {
78- // Get asset type from @key
79- parts := strings .Split (k ["@key" ].(string ), ":" )
80- if len (parts ) < 2 {
81- err = errors .NewCCError ("cannot determine asset type from key" , 400 )
82- return
83- }
84- k ["@assetType" ] = parts [0 ]
85- }
86-
8783 for t := range k {
8884 if t != "@key" && t != "@assetType" {
8985 delete (k , t )
You can’t perform that action at this time.
0 commit comments