MCPcopy Create free account
hub / github.com/Superflows-AI/superflows / parseErrorHtml

Function parseErrorHtml

lib/edge-runtime/utils.ts:312–337  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

310}
311
312export function parseErrorHtml(str: string): string {
313 const elements = [];
314 const regexes = [
315 /<title.*?>([\s\S]*?)<\/title>/g,
316 /<h1.*?>([\s\S]*?)<\/h1>/g,
317 /<h2.*?>([\s\S]*?)<\/h2>/g,
318 /<h3.*?>([\s\S]*?)<\/h3>/g,
319 ];
320 for (const regex of regexes) {
321 let match = str.match(regex);
322 if (match) {
323 elements.push(
324 match
325 .map((m) =>
326 m
327 .match(/<.*?>([\s\S]*?)<\/.*?>/)![1]
328 .trim()
329 .replace(/\s+/g, " "),
330 )
331 .join(" "),
332 );
333 }
334 }
335 const result = elements.filter(Boolean).join("\n");
336 return result.length > 0 ? result : str;
337}
338
339export function replaceVariables(
340 input: string,

Callers 2

makeHttpRequestFunction · 0.90
utils.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected