Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion staticalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 10 additions & 2 deletions test/staticalize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ describe("staticalize", () => {
let listening = Promise.withResolvers<Deno.NetAddr>();

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);

Expand Down Expand Up @@ -67,10 +70,15 @@ describe("staticalize", () => {
"<html><head></head><body><h1>Contact</h1></body></html>",
);

let xml = parse(await Deno.readTextFile("test/dist/sitemap.xml"));
let text = await Deno.readTextFile("test/dist/sitemap.xml");

// entries are `<url>`, as https://www.sitemaps.org/protocol.html requires
expect(text).not.toContain("<urls>");

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",
Expand Down
Loading