Detect JSON APIs returning HTML content-type

This commit is contained in:
Gregory Schier committed 2024-08-29 10:52:41 -07:00
1 parent 0d20e0fe29
commit f8936e7b76
5 files changed
+66 -21

No files matched your search

+9
View File
@@ -14,3 +14,12 @@ export function languageFromContentType(contentType: string | null): EditorProps
return 'text';
}
}
export function isJSON(text: string): boolean {
try {
JSON.parse(text);
return true;
} catch (_) {
return false;
}
}