improve preview for videos by showing the streaming response as it comes in

This commit is contained in:
Abi Raja 2024-03-08 12:37:37 -05:00
parent cacf78a4bb
commit f09b4c7808

View File

@ -1,4 +1,16 @@
// Not robust enough to support <html lang='en'> for instance
export function extractHtml(code: string): string { export function extractHtml(code: string): string {
const htmlStartIndex = code.indexOf("<html>"); const lastHtmlStartIndex = code.lastIndexOf("<html>");
return htmlStartIndex !== -1 ? code.slice(htmlStartIndex) : ""; let htmlEndIndex = code.indexOf("</html>", lastHtmlStartIndex);
if (lastHtmlStartIndex !== -1) {
// If "</html>" is found, adjust htmlEndIndex to include the "</html>" tag
if (htmlEndIndex !== -1) {
htmlEndIndex += "</html>".length;
return code.slice(lastHtmlStartIndex, htmlEndIndex);
}
// If "</html>" is not found, return the rest of the string starting from the last "<html>"
return code.slice(lastHtmlStartIndex);
}
return "";
} }