mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Added handling for empty query options
refs #9866 - it's fine if you pass e.g. `?formats=` - same behaviour as v0.1
This commit is contained in:
parent
5d3b026cd9
commit
27714075b5
2 changed files with 22 additions and 0 deletions
|
@ -49,6 +49,11 @@ const validate = (config, attrs) => {
|
|||
if (allowedValues) {
|
||||
debug('ctrl validation');
|
||||
|
||||
// CASE: we allow e.g. `formats=`
|
||||
if (!value || !value.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const valuesAsArray = value.trim().toLowerCase().split(',');
|
||||
const unallowedValues = _.filter(valuesAsArray, (value) => {
|
||||
return !allowedValues.includes(value);
|
||||
|
|
|
@ -61,6 +61,23 @@ describe('Unit: api/shared/validators/input/all', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('allows empty values', function () {
|
||||
const frame = {
|
||||
options: {
|
||||
context: {},
|
||||
formats: ''
|
||||
}
|
||||
};
|
||||
|
||||
const apiConfig = {
|
||||
options: {
|
||||
formats: ['format1']
|
||||
}
|
||||
};
|
||||
|
||||
return shared.validators.input.all.all(apiConfig, frame);
|
||||
});
|
||||
|
||||
it('default include array notation', function () {
|
||||
const frame = {
|
||||
options: {
|
||||
|
|
Loading…
Add table
Reference in a new issue