MDL-77003 javascript: improve string helper JSON detection.

Changes in fbc2732d made the JS template string helper method
too strict in regards to what it considers a valid JSON object.

Co-authored-by: Mike Churchward <mike@brickfieldlabs.ie>
This commit is contained in:
Paul Holden 2023-01-23 23:59:48 +00:00
parent 8de12b7997
commit 0a86c6a123
3 changed files with 3 additions and 4 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -558,8 +558,7 @@ function(
}
// Allow json formatted $a arguments.
// Added double quote after left curly bracket to differentiate between string and JSON string.
if (param.indexOf('{"') === 0) {
if (param.match(/^{\s*"/gm)) {
// If it can't be parsed then the string is not a JSON format.
try {
const parsedParam = JSON.parse(param);