improve preview for videos by showing the streaming response as it comes in
This commit is contained in:
parent
cacf78a4bb
commit
f09b4c7808
@ -1,4 +1,16 @@
|
||||
// Not robust enough to support <html lang='en'> for instance
|
||||
export function extractHtml(code: string): string {
|
||||
const htmlStartIndex = code.indexOf("<html>");
|
||||
return htmlStartIndex !== -1 ? code.slice(htmlStartIndex) : "";
|
||||
const lastHtmlStartIndex = code.lastIndexOf("<html>");
|
||||
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 "";
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user