Fix: Handle non-string values in escape utilities

Co-authored-by: gemini-3.5-flash <gemini@google.com>
This commit is contained in:
2026-05-31 13:32:43 -07:00
parent 8d272a971a
commit 4ba2662db2

View File

@@ -4,10 +4,10 @@ export const fmtDate = (date) =>
export const toISODate = (d) => new Date(d).toISOString().split("T")[0];
export const escapeHtml = (s = "") =>
s.replace(/[&<>"']/g, (ch) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }[ch]));
String(s ?? "").replace(/[&<>"']/g, (ch) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }[ch]));
export const escapeXml = (s = "") =>
s.replace(/[<>&'"]/g, (ch) => ({ "<": "&lt;", ">": "&gt;", "&": "&amp;", "'": "&apos;", '"': "&quot;" }[ch]));
String(s ?? "").replace(/[<>&'"]/g, (ch) => ({ "<": "&lt;", ">": "&gt;", "&": "&amp;", "'": "&apos;", '"': " &quot;" }[ch]));
export const fixInternalLinks = (html) =>
html