From 87ab5cb1c3293d965b18b18d34a0c0a28d4a57c5 Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sat, 26 Sep 2026 08:21:29 -0400 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=85=20let=20the=20test=20server=20pic?= =?UTF-8?q?k=20a=20free=20port?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The suite bound deno's default port 8000, so it failed with `AddrInUse` whenever anything else on the machine was already listening there. --- test/staticalize.test.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/staticalize.test.ts b/test/staticalize.test.ts index 470ce37..946e9ff 100644 --- a/test/staticalize.test.ts +++ b/test/staticalize.test.ts @@ -23,6 +23,9 @@ describe("staticalize", () => { let listening = Promise.withResolvers(); server = Deno.serve({ + // port 0 asks the os for a free port, so the suite does not collide with + // whatever happens to be on deno's default 8000 + port: 0, onListen: (addr) => listening.resolve(addr), }, app.fetch); From 0cd2d01415d518183a490d5ec66c670cd4a040d5 Mon Sep 17 00:00:00 2001 From: Taras Mankovski Date: Sat, 26 Sep 2026 08:21:54 -0400 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=90=9B=20write=20sitemap=20entries=20?= =?UTF-8?q?as=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The sitemap writer passed `urls` as the entry key, so every generated sitemap wrapped its `` in `` and was invalid per https://www.sitemaps.org/protocol.html. It went unnoticed because our own reader accepts either spelling, so a site staticalized twice round-trips its own invalid output. The reader keeps accepting `urls` so sitemaps already deployed by earlier versions can still be crawled. Closes #14 --- staticalize.ts | 2 +- test/staticalize.test.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/staticalize.ts b/staticalize.ts index 3a4ebbe..aa13758 100644 --- a/staticalize.ts +++ b/staticalize.ts @@ -93,7 +93,7 @@ export function useStaticalizer( let xml = stringify({ urlset: { "@xmlns": "http://www.sitemaps.org/schemas/sitemap/0.9", - "urls": [...urls].map((url) => { + "url": [...urls].map((url) => { let loc = new URL(url); loc.host = base.host; loc.port = base.port; diff --git a/test/staticalize.test.ts b/test/staticalize.test.ts index 946e9ff..c9160f0 100644 --- a/test/staticalize.test.ts +++ b/test/staticalize.test.ts @@ -70,10 +70,15 @@ describe("staticalize", () => { "

Contact

", ); - let xml = parse(await Deno.readTextFile("test/dist/sitemap.xml")); + let text = await Deno.readTextFile("test/dist/sitemap.xml"); + + // entries are ``, as https://www.sitemaps.org/protocol.html requires + expect(text).not.toContain(""); + + let xml = parse(text); //@ts-expect-error this is an unknown xml doc - let [one, two, three] = xml.urlset.urls.map((u) => u.loc); + let [one, two, three] = xml.urlset.url.map((u) => u.loc); expect([one, two, three]).toEqual([ "https://frontside.com/", "https://frontside.com/about",