Skip to content

Commit 9352759

Browse files
committed
fix(json): remove extra spaces to improve fixJson success rate
1 parent 600aaf5 commit 9352759

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

utils/json.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export type DeepPartial<T> = T extends object
88
: T
99

1010
export function removeJsonMarkdown(text: string) {
11+
text = text.trim()
1112
if (text.startsWith('```json')) {
1213
text = text.slice(7)
1314
} else if (text.startsWith('json')) {
@@ -18,7 +19,7 @@ export function removeJsonMarkdown(text: string) {
1819
if (text.endsWith('```')) {
1920
text = text.slice(0, -3)
2021
}
21-
return text
22+
return text.trim()
2223
}
2324

2425
/**

0 commit comments

Comments
 (0)