feat: de-duplicate <Head> children by key (#1793)

This commit is contained in:
Marvin Hagemeister
2023-09-18 22:06:56 +02:00
committed by GitHub
parent 58b2bd9e7f
commit 567df19f3d
7 changed files with 255 additions and 112 deletions
+16
View File
@@ -955,3 +955,19 @@ Deno.test({
});
},
});
Deno.test("De-duplicates <Head /> nodes by key", async () => {
await withFakeServe("./tests/fixture/main.ts", async (server) => {
const res = await server.get(`/head_deduplicate`);
const html = await res.text();
assertEquals(Array.from(html.matchAll(/<title>/g)).length, 1);
assert(/<title>bar<\/title>/.test(html));
assertEquals(
Array.from(html.matchAll(/<meta property="og:title"/g)).length,
1,
);
assert(/<meta property="og:title" content="Other title"\/>/.test(html));
});
});