mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-24 02:11:10 +01:00
Detect JSON APIs returning HTML content-type
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user