Skip to content

Commit e521553

Browse files
authored
Adjust the grabJson regex to be more forgiving on whitespaces (#944)
1 parent d72edfb commit e521553

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

charm/src/iframe/static.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ ${JSON.stringify(libraries)}
168168
window.grabJson = (gstr) => {
169169
// Function to extract and parse JSON from a string
170170
// This handles both raw JSON strings and code blocks with JSON
171-
const jsonRegex = /\`\`\`(?:json)?[\\s\\n]*([\\s\\S]*?)[\\s\\n]*\`\`\`|(\\{[\\s\\S]*?\\})/;
171+
const jsonRegex = /\`\`\`(?:json)?\s*([\s\S]*?)\s*\`\`\`|({[\s\S]*})/;
172172
const match = gstr.match(jsonRegex);
173173
174174
if (match) {

0 commit comments

Comments
 (0)