Skip to content

Commit 68bd7fe

Browse files
Merge pull request #592 from microsoft/psl-bug-25292
fix: When clicking Generate Draft from the Generate page (which navigates to the Draft page), the console displayed a JSON parse error
2 parents 8cc24f1 + 5073e5e commit 68bd7fe

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/frontend/src/helpers/helpers.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ export const parseCitationFromMessage = (message: ChatMessage) => {
2828

2929
export const cleanJSON = (jsonString: string) => {
3030
try {
31+
// Check if the string contains JSON-like patterns before processing
32+
if (!jsonString.includes('{') || !jsonString.includes('}')) {
33+
return ''
34+
}
35+
3136
let lines: string[]
3237
let cleanString = ''
3338
lines = jsonString.split('\n')

0 commit comments

Comments
 (0)