@inglorious/ssx 2.1.6 → 2.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/render/layout.js +0 -1
- package/src/render/layout.test.js +24 -0
package/package.json
CHANGED
package/src/render/layout.js
CHANGED
|
@@ -33,7 +33,6 @@ export function layout(body, options) {
|
|
|
33
33
|
${prescripts
|
|
34
34
|
.map((src) => `<script type="text/javascript" src="${src}"></script>`)
|
|
35
35
|
.join("\n")}
|
|
36
|
-
${head}
|
|
37
36
|
<meta charset="${charset}" />
|
|
38
37
|
<title>${title}</title>
|
|
39
38
|
<link rel="icon" type="image/x-icon" href="${favicon}">
|
|
@@ -44,6 +44,30 @@ describe("layout", () => {
|
|
|
44
44
|
expect(html).toContain('<link rel="icon" href="/favicon.ico">')
|
|
45
45
|
})
|
|
46
46
|
|
|
47
|
+
it("should emit head content exactly once", () => {
|
|
48
|
+
const html = layout("", {
|
|
49
|
+
head: '<link rel="alternate" hreflang="it" href="https://x.test/it">',
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
expect(
|
|
53
|
+
html.match(/hreflang="it"/g),
|
|
54
|
+
"head content must not be duplicated",
|
|
55
|
+
).toHaveLength(1)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it("should keep meta charset ahead of head content", () => {
|
|
59
|
+
const head = `<link rel="preload" href="/${"a".repeat(1200)}.woff2" as="font">`
|
|
60
|
+
const html = layout("", { head })
|
|
61
|
+
|
|
62
|
+
const charset = html.indexOf("<meta charset")
|
|
63
|
+
const headStart = html.indexOf(head)
|
|
64
|
+
|
|
65
|
+
expect(charset).toBeGreaterThan(-1)
|
|
66
|
+
expect(headStart).toBeGreaterThan(charset)
|
|
67
|
+
// Browsers only prescan the first 1024 bytes to detect the encoding.
|
|
68
|
+
expect(charset).toBeLessThan(1024)
|
|
69
|
+
})
|
|
70
|
+
|
|
47
71
|
it("should include vite client in dev mode", () => {
|
|
48
72
|
const html = layout("", { isDev: true })
|
|
49
73
|
expect(html).toContain(
|