mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-11 20:00:29 +01:00
Ignore whitespace during content type detection
This commit is contained in:
@@ -74,7 +74,6 @@ impl PluginHandle {
|
||||
}
|
||||
|
||||
pub async fn set_boot_response(&self, resp: &BootResponse) {
|
||||
info!("BOOTED PLUGIN {:?}", resp);
|
||||
let mut boot_resp = self.boot_resp.lock().await;
|
||||
*boot_resp = resp.clone();
|
||||
}
|
||||
|
||||
@@ -25,14 +25,17 @@ function detectFromContent(
|
||||
): EditorProps['language'] {
|
||||
if (content == null) return 'text';
|
||||
|
||||
if (content.startsWith('{') || content.startsWith('[')) {
|
||||
const firstBytes = content.slice(0, 20).trim();
|
||||
console.log("FIRST BYTES", firstBytes);
|
||||
|
||||
if (firstBytes.startsWith('{') || firstBytes.startsWith('[')) {
|
||||
return 'json';
|
||||
} else if (
|
||||
content.toLowerCase().startsWith('<!doctype') ||
|
||||
content.toLowerCase().startsWith('<html')
|
||||
firstBytes.toLowerCase().startsWith('<!doctype') ||
|
||||
firstBytes.toLowerCase().startsWith('<html')
|
||||
) {
|
||||
return 'html';
|
||||
} else if (content.startsWith('<')) {
|
||||
} else if (firstBytes.startsWith('<')) {
|
||||
return 'xml';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user