first commit

This commit is contained in:
2026-07-12 15:55:18 +05:30
commit ee98026cc5
404 changed files with 44522 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
import { expect, test } from "bun:test";
import { fontCspSources, renderFontHead } from "../src/index.ts";
test("renders subsetted Google and escaped local font markup", () => {
const html = renderFontHead({
google: [{ family: "Inter", weights: [700, 400] }],
local: [
{
family: 'Bad"</style><script>x</script>',
src: '/font".woff2',
preload: true,
},
],
});
expect(html).toContain("family=Inter:wght@400;700");
expect(html).not.toContain("</style><script>");
expect(html).toContain("&quot;");
expect(fontCspSources({ google: [{ family: "Inter" }] })).toEqual({
style: ["https://fonts.googleapis.com"],
font: ["https://fonts.gstatic.com"],
});
});