(source: string)
| 438 | |
| 439 | // Helper function used to convert raw text files to html |
| 440 | export function escapeHtml(source: string): string { |
| 441 | const entityMap = new Map<string, string>(Object.entries({ |
| 442 | '&': '&', |
| 443 | '<': '<', |
| 444 | '>': '>', |
| 445 | '"': '"', |
| 446 | '\'': ''', |
| 447 | '/': '/' |
| 448 | })); |
| 449 | return String(source).replace(/[&<>"'/]/g, (s: string) => entityMap.get(s) || ''); |
| 450 | } |
| 451 | |
| 452 | // creates a directory if it doesn't exist, |
| 453 | // returns the input string |
no test coverage detected