Something went wrong. Try again.
Monorepo for Tangled forked from tangled.org/core
Something went wrong. Try again.
123456789101112131415161718import { describe, expect, it } from "vitest";import { serializeJsonLd } from "#lib/seo/jsonLd.ts";
describe("serializeJsonLd", () => { it("cannot close the surrounding script tag", () => { const out = serializeJsonLd({ description: "</script><script>alert(1)</script>" }); expect(out).not.toMatch(/[<>]/); expect(out).toContain("\\u003c/script\\u003e"); });
it("round-trips to the same value", () => { const schema = { name: "a & b", description: "x < y > z \u2028 \u2029 <!--" }; const out = serializeJsonLd(schema); expect(out).not.toMatch(/[&\u2028\u2029]/); expect(JSON.parse(out)).toEqual(schema); });});