| 147 | this.set(CONFIG_KEYS.PROMPT_MAP, JSON.stringify(map)); |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | const decodeHtmlEntities = (text: string): string => |
| 152 | text |
| 153 | .replace(/&#(\d+);/g, (_match, code) => { |
| 154 | const value = Number.parseInt(code, 10); |
| 155 | return Number.isFinite(value) ? String.fromCodePoint(value) : _match; |
| 156 | }) |
| 157 | .replace(/&#x([0-9a-f]+);/gi, (_match, code) => { |
| 158 | const value = Number.parseInt(code, 16); |
| 159 | return Number.isFinite(value) ? String.fromCodePoint(value) : _match; |
| 160 | }) |
| 161 | .replace(/&(amp|lt|gt|quot|apos|nbsp);/gi, (match, entity) => { |
| 162 | switch (entity.toLowerCase()) { |
| 163 | case "amp": |