Merge pull request #183 from LoicMahieu/fix/182
parse config: should ignore null values
This commit is contained in:
commit
47974fd1d2
|
@ -400,6 +400,8 @@ function getUpdatedConfigObject(app, config, opts) {
|
||||||
interpolated[configKey] = value.map(interpolateVariables);
|
interpolated[configKey] = value.map(interpolateVariables);
|
||||||
} else if (typeof value === 'string') {
|
} else if (typeof value === 'string') {
|
||||||
interpolated[configKey] = getConfigVariable(value);
|
interpolated[configKey] = getConfigVariable(value);
|
||||||
|
} else if (value === null) {
|
||||||
|
interpolated[configKey] = value;
|
||||||
} else if (typeof value === 'object' && Object.keys(value).length) {
|
} else if (typeof value === 'object' && Object.keys(value).length) {
|
||||||
interpolated[configKey] = interpolateVariables(value);
|
interpolated[configKey] = interpolateVariables(value);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -543,6 +543,23 @@ describe('executor', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should parse config variables with null values', function(done) {
|
||||||
|
boot.execute(app, simpleMiddlewareConfig('routes',
|
||||||
|
{ nested: { info: { path: '${restApiRoot}', some: null }}}
|
||||||
|
));
|
||||||
|
|
||||||
|
supertest(app).get('/').end(function(err, res) {
|
||||||
|
if (err) return done(err);
|
||||||
|
expect(res.body.nested).to.eql({
|
||||||
|
info: {
|
||||||
|
path: app.get('restApiRoot'),
|
||||||
|
some: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should not parse invalid config variables', function(done) {
|
it('should not parse invalid config variables', function(done) {
|
||||||
var invalidDataTypes = [undefined, function() {}];
|
var invalidDataTypes = [undefined, function() {}];
|
||||||
async.each(invalidDataTypes, function(invalidDataType, cb) {
|
async.each(invalidDataTypes, function(invalidDataType, cb) {
|
||||||
|
|
Loading…
Reference in New Issue