From 93527597b77f23fca0989de294ad06fb61884ee4 Mon Sep 17 00:00:00 2001 From: AnotiaWang Date: Fri, 14 Feb 2025 12:01:35 +0800 Subject: [PATCH] fix(json): remove extra spaces to improve `fixJson` success rate --- utils/json.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/json.ts b/utils/json.ts index 275841d..2d20251 100644 --- a/utils/json.ts +++ b/utils/json.ts @@ -8,6 +8,7 @@ export type DeepPartial = 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() } /**