mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-22 08:38:29 +02: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) {
|
pub async fn set_boot_response(&self, resp: &BootResponse) {
|
||||||
info!("BOOTED PLUGIN {:?}", resp);
|
|
||||||
let mut boot_resp = self.boot_resp.lock().await;
|
let mut boot_resp = self.boot_resp.lock().await;
|
||||||
*boot_resp = resp.clone();
|
*boot_resp = resp.clone();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,14 +25,17 @@ function detectFromContent(
|
|||||||
): EditorProps['language'] {
|
): EditorProps['language'] {
|
||||||
if (content == null) return 'text';
|
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';
|
return 'json';
|
||||||
} else if (
|
} else if (
|
||||||
content.toLowerCase().startsWith('<!doctype') ||
|
firstBytes.toLowerCase().startsWith('<!doctype') ||
|
||||||
content.toLowerCase().startsWith('<html')
|
firstBytes.toLowerCase().startsWith('<html')
|
||||||
) {
|
) {
|
||||||
return 'html';
|
return 'html';
|
||||||
} else if (content.startsWith('<')) {
|
} else if (firstBytes.startsWith('<')) {
|
||||||
return 'xml';
|
return 'xml';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user