fix(json): remove extra spaces to improve fixJson success rate

This commit is contained in:
AnotiaWang
2025-02-14 12:01:35 +08:00
parent 600aaf53e1
commit 93527597b7

View File

@ -8,6 +8,7 @@ export type DeepPartial<T> = T extends object
: T
export function removeJsonMarkdown(text: string) {
text = text.trim()
if (text.startsWith('```json')) {
text = text.slice(7)
} else if (text.startsWith('json')) {
@ -18,7 +19,7 @@ export function removeJsonMarkdown(text: string) {
if (text.endsWith('```')) {
text = text.slice(0, -3)
}
return text
return text.trim()
}
/**