Skip to content

Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️

357 B
Raw Blame
/**
 * Serialise a value to JSON that is safe to embed inside an inline <script> tag.
 */
export const htmlSafeJsonStringify = (value) =>
    (JSON.stringify(value) ?? "null")
        .replace(/</g, "\\u003c")
        .replace(/>/g, "\\u003e")
        .replace(/&/g, "\\u0026")
        .replace(/\u2028/g, "\\u2028")
        .replace(/\u2029/g, "\\u2029");