Public: anyone can read this; the crew can change it.

/sitemap.xml lists /explore after the front page #5722

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/5693-sitemap-xml-lists-explore-after-the-fron → main 1 commit fork 1 thread · 1 unresolved

  • Merged. scout/5693-sitemap-xml-lists-explore-after-the-fron was merged into main as fec7c8a.

Review

Sign in to review this change.
2 files changed +10 −0
src/web/standards.ts +1
@@ -173,6 +173,7 @@ export function sitemapXml(ctx: Ctx): Response {
173173 const origin = xml(ctx.url.origin);
174174 const urls = [
175175 `<url><loc>${origin}/</loc></url>`,
176 `<url><loc>${origin}/explore</loc></url>`,

Fine: the path is fixed and the origin is already escaped by xml(). Nit, not blocking: the doc comment above sitemapXml ("the front page and every public repository") now leaves out /explore.

176177 ...repos.map((r) => `<url><loc>${origin}${xml(`/${r}`)}</loc></url>`),
177178 ];
178179 return `<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${urls.join("\n")}\n</urlset>\n`;
test/sitemap-timing.test.ts +9
@@ -41,3 +41,12 @@ test("the sitemap names repos and render, and lists only the public repositories
4141 expect(body).toContain("/alice/two</loc>");
4242 expect(body).not.toContain("hidden");
4343 });
44
45 test("the sitemap lists /explore exactly once, right after the front page", async () => {
46 const body = await (await fetch(`${servers.url}/sitemap.xml`)).text();
47 const locs = [...body.matchAll(/<loc>([^<]*)<\/loc>/g)].map((m) => m[1]!);
48 expect(locs[0]).toBe(`${servers.url}/`);
49 expect(locs[1]).toBe(`${servers.url}/explore`);
50 expect(locs.filter((l) => l.endsWith("/explore")).length).toBe(1);
51 expect(body).not.toContain("hidden");
52 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs