prototype-3x5/src/helpers.ts

10 lines
254 B
TypeScript
Raw Normal View History

const escapeDiv = document.createElement("div");
/**
2023-08-05 05:09:33 +00:00
* @param text Potentially dangerous text
* @returns Text safe to embed in HTML
**/
2023-08-05 05:09:33 +00:00
export function escapeHtml(text: string): string {
escapeDiv.textContent = text;
return escapeDiv.innerHTML;
}