(content: string)
| 97 | const XML_START = /^<\?xml\s|^<msg[\s>]/ |
| 98 | |
| 99 | function cleanXmlContent(content: string): string { |
| 100 | const trimmed = content.trim() |
| 101 | if (!XML_START.test(trimmed)) return content |
| 102 | |
| 103 | const title = extractXmlTag(trimmed, 'title') |
| 104 | const des = extractXmlTag(trimmed, 'des') |
| 105 | |
| 106 | if (title) { |
| 107 | return des ? `[分享] ${title} - ${des}` : `[分享] ${title}` |
| 108 | } |
| 109 | return '[应用消息]' |
| 110 | } |
| 111 | |
| 112 | function extractXmlTag(xml: string, tag: string): string | null { |
| 113 | const openTag = `<${tag}>` |
no test coverage detected