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 <[email protected]>
This commit is contained in:
Paul Holden
2023-01-24 22:16:21 +00:00
co-authored by Mike Churchward
parent 8de12b7997
commit 0a86c6a123
3 changed files with 3 additions and 4 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -2
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);