0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Improve config-parser JSON handling

closes #5294

This improves a hack for parsing JSON to be more robust.
Now attempt to parse JSON, and if it's not possible it will fallback to treating the value is a string,
reverting the behaviour to what it would have been if we didn't have JSON parsing here.
This commit is contained in:
Hannah Wolfe 2015-05-21 09:21:47 +01:00
parent 9a9fbd906a
commit 1142561532

View file

@ -12,7 +12,12 @@ var isNumeric = function (num) {
} else if (isNumeric(val)) {
return +val;
} else if (val.indexOf('{') === 0) {
return JSON.parse(val);
try {
return JSON.parse(val);
} catch (e) {
/*jshint unused:false */
return val;
}
} else {
return val;
}