mirror of
https://github.com/strapi/strapi.git
synced 2025-09-26 00:39:49 +00:00
In sanitize input leave input data as is if model is not found
Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
parent
ac2cbcd90e
commit
50a68e9f45
@ -290,9 +290,14 @@ describe('Sanitize Entity', () => {
|
||||
});
|
||||
|
||||
describe('Edge cases', () => {
|
||||
test('It returns data if the model is nil', () => {
|
||||
expect(sanitizeEntity(input, { model: null })).toEqual(input);
|
||||
expect(sanitizeEntity(input, { model: undefined })).toEqual(input);
|
||||
test('It returns the input data if the model is nil and isOutput false', () => {
|
||||
expect(sanitizeEntity(input, { model: null, isOutput: false })).toEqual(input);
|
||||
expect(sanitizeEntity(input, { model: undefined, isOutput: false })).toEqual(input);
|
||||
});
|
||||
|
||||
test('It returns null if the model is nil and isOutput true', () => {
|
||||
expect(sanitizeEntity(input, { model: null })).toBeNull();
|
||||
expect(sanitizeEntity(input, { model: undefined })).toBeNull();
|
||||
});
|
||||
|
||||
test(`It returns the input data as-is if it's not an object or an array`, () => {
|
||||
|
@ -28,7 +28,11 @@ const sanitizeEntity = (dataSource, options) => {
|
||||
}
|
||||
|
||||
if (_.isNil(model)) {
|
||||
return data;
|
||||
if (isOutput) {
|
||||
return null;
|
||||
} else {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
const { attributes } = model;
|
||||
|
Loading…
x
Reference in New Issue
Block a user