strapi-utils
Advanced tools
Comparing version 3.5.0-next.2 to 3.5.0-next.3
@@ -64,4 +64,3 @@ 'use strict'; | ||
const nextOptions = { | ||
model: strapi.getModel(relation, attribute.plugin), | ||
const baseOptions = { | ||
withPrivate, | ||
@@ -72,6 +71,19 @@ isOutput, | ||
const nextVal = Array.isArray(value) | ||
? value.map(elem => sanitizeEntity(elem, nextOptions)) | ||
: sanitizeEntity(value, nextOptions); | ||
let sanitizeFn; | ||
if (relation === '*') { | ||
sanitizeFn = entity => | ||
sanitizeEntity(entity, { | ||
model: strapi.db.getModelByGlobalId(entity.__contentType), | ||
...baseOptions, | ||
}); | ||
} else { | ||
sanitizeFn = entity => | ||
sanitizeEntity(entity, { | ||
model: strapi.getModel(relation, attribute.plugin), | ||
...baseOptions, | ||
}); | ||
} | ||
const nextVal = Array.isArray(value) ? value.map(sanitizeFn) : sanitizeFn(value); | ||
return { ...acc, [key]: nextVal }; | ||
@@ -78,0 +90,0 @@ } |
{ | ||
"name": "strapi-utils", | ||
"version": "3.5.0-next.2", | ||
"version": "3.5.0-next.3", | ||
"description": "Shared utilities for the Strapi packages", | ||
@@ -48,3 +48,3 @@ "homepage": "https://strapi.io", | ||
"license": "SEE LICENSE IN LICENSE", | ||
"gitHead": "fe695e98219eb035a741a1baeb3334b561c81728" | ||
"gitHead": "7102ebbcef1716b55f8a2ce8370f2cb1bd719a8a" | ||
} |
58822
1694