| 171 | } |
| 172 | |
| 173 | export function parseErrorHtml(str: string): string { |
| 174 | const elements = []; |
| 175 | const regexes = [ |
| 176 | /<title.*?>(.*)<\/title>/, |
| 177 | /<h1.*?>(.*)<\/h1>/, |
| 178 | /<h2.*?>(.*)<\/h2>/, |
| 179 | /<h3.*?>(.*)<\/h3>/, |
| 180 | ]; |
| 181 | for (const regex of regexes) { |
| 182 | const match = str.match(regex); |
| 183 | if (match) { |
| 184 | elements.push(match[1].trim().replace(/\s+/g, " ")); |
| 185 | } |
| 186 | } |
| 187 | const result = elements.filter(Boolean).join("\n"); |
| 188 | return result.length > 0 ? result : str; |
| 189 | } |
| 190 | |
| 191 | export function formatString() { |
| 192 | const args = Array.prototype.slice.call(arguments); |