MCPcopy
hub / github.com/anomalyco/models.dev / escapeHtml

Function escapeHtml

packages/web/src/shared.ts:15–32  ·  view source on GitHub ↗
(value: string | number)

Source from the content-addressed store, hash-verified

13};
14
15export function escapeHtml(value: string | number) {
16 return String(value).replace(/[&<>'"]/g, (char) => {
17 switch (char) {
18 case "&":
19 return "&amp;";
20 case "<":
21 return "&lt;";
22 case ">":
23 return "&gt;";
24 case "'":
25 return "&#39;";
26 case '"':
27 return "&quot;";
28 default:
29 return char;
30 }
31 });
32}
33
34export function booleanText(value?: boolean) {
35 if (value === undefined) return "-";

Callers 1

renderDocumentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected