0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

🐛 Theme name is point number (#9184)

closes #9182

- e.g. "1.4"
- extend settings cache to ensure we return strings for numbers and floating point numbers
This commit is contained in:
Katharina Irrgang 2017-10-26 13:54:18 +02:00 committed by GitHub
parent 07dcbb0d53
commit 34054a32c0
2 changed files with 6 additions and 1 deletions

View file

@ -50,7 +50,7 @@ module.exports = {
// Default behaviour is to try to resolve the value and return that
try {
// CASE: if a string contains a number e.g. "1", JSON.parse will auto convert into integer
if (settingsCache[key].value.match(/^\d+$/)) {
if (!isNaN(Number(settingsCache[key].value))) {
return settingsCache[key].value;
}

View file

@ -10,6 +10,11 @@ describe('UNIT: settings cache', function () {
(typeof cache.get('key1')).should.eql('string');
});
it('does not auto convert string into number: float', function () {
cache.set('key1', {value: '1.4'});
(typeof cache.get('key1')).should.eql('string');
});
it('stringified JSON get\'s parsed', function () {
cache.set('key2', {value: '{"a":"1","b":"hallo","c":{"d":[]},"e":2}'});
(typeof cache.get('key2')).should.eql('object');