mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 17:18:32 +02:00
Don't switch to XML for HTML responses.
Fixes https://feedback.yaak.app/p/issue-with-rendering-html-responses-after-update
This commit is contained in:
@@ -11,7 +11,13 @@ export function languageFromContentType(
|
|||||||
} else if (justContentType.includes('xml')) {
|
} else if (justContentType.includes('xml')) {
|
||||||
return 'xml';
|
return 'xml';
|
||||||
} else if (justContentType.includes('html')) {
|
} else if (justContentType.includes('html')) {
|
||||||
return detectFromContent(content, 'html');
|
const detected = detectFromContent(content, 'html');
|
||||||
|
if (detected === 'xml') {
|
||||||
|
// If it's detected as XML, but is already HTML, don't change it
|
||||||
|
return 'html';
|
||||||
|
} else {
|
||||||
|
return detected;
|
||||||
|
}
|
||||||
} else if (justContentType.includes('javascript')) {
|
} else if (justContentType.includes('javascript')) {
|
||||||
return 'javascript';
|
return 'javascript';
|
||||||
}
|
}
|
||||||
@@ -26,7 +32,6 @@ function detectFromContent(
|
|||||||
if (content == null) return 'text';
|
if (content == null) return 'text';
|
||||||
|
|
||||||
const firstBytes = content.slice(0, 20).trim();
|
const firstBytes = content.slice(0, 20).trim();
|
||||||
console.log("FIRST BYTES", firstBytes);
|
|
||||||
|
|
||||||
if (firstBytes.startsWith('{') || firstBytes.startsWith('[')) {
|
if (firstBytes.startsWith('{') || firstBytes.startsWith('[')) {
|
||||||
return 'json';
|
return 'json';
|
||||||
|
|||||||
Reference in New Issue
Block a user