MCPcopy Index your code
hub / github.com/codeaashu/claude-code / sanitizeMessageHTML

Function sanitizeMessageHTML

src/services/api/errorUtils.ts:107–116  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

105 * Returns the original message unchanged if no HTML is found.
106 */
107function 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)

Callers 2

sanitizeAPIErrorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected