mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-13 16:03:35 +02:00
if not in defaults use string
This commit is contained in:
@@ -22,7 +22,7 @@ function deserialize(config) {
|
||||
const defaultType = typeof defaults[key];
|
||||
const type = typeof config[key];
|
||||
|
||||
if (defaultType === 'string' && type === 'number') {
|
||||
if ((defaultType === 'string' || defaultType === 'undefined') && type === 'number') {
|
||||
deserialized[key] = String(config[key]);
|
||||
} else if (defaultType === 'number' && type === 'string') {
|
||||
const number = parseFloat(config[key]);
|
||||
|
||||
@@ -213,12 +213,12 @@ describe('meta', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('should set numeric config value', function (done) {
|
||||
it('should get back string if field is not in defaults', function (done) {
|
||||
meta.configs.set('numericField', 123, function (err) {
|
||||
assert.ifError(err);
|
||||
meta.configs.getFields(['numericField'], function (err, data) {
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(data.numericField, 123);
|
||||
assert.strictEqual(data.numericField, '123');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user