All files / src/core escape.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 2/2
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 68x     8x 3341x  
const ENTITIES: Record<string, string> = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" };
 
/** Escapes text for use inside HTML or SVG markup, in content or attribute values. */
export const escape = (text: string | number): string =>
  String(text).replace(/[&<>"']/g, (c) => ENTITIES[c]);