* Strips HTML content (e.g., CloudFlare error pages) from a message string, * returning a user-friendly title or empty string if HTML is detected. * Returns the original message unchanged if no HTML is found.
(message: string)
| 105 | * Returns the original message unchanged if no HTML is found. |
| 106 | */ |
| 107 | function sanitizeMessageHTML(message: string): string { |
| 108 | if (message.includes('<!DOCTYPE html') || message.includes('<html')) { |
| 109 | const titleMatch = message.match(/<title>([^<]+)<\/title>/) |
| 110 | if (titleMatch && titleMatch[1]) { |
| 111 | return titleMatch[1].trim() |
| 112 | } |
| 113 | return '' |
| 114 | } |
| 115 | return message |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Detects if an error message contains HTML content (e.g., CloudFlare error pages) |
no outgoing calls
no test coverage detected