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 470ce37..c9160f0 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); @@ -67,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",