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:
parent
9a9fbd906a
commit
1142561532
1 changed files with 6 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue