From d0e0f921152b103592d2671495c0486426af67ba Mon Sep 17 00:00:00 2001 From: Victor Bertram Date: Fri, 27 Mar 2026 09:51:45 -0300 Subject: [PATCH] fix: filter sitemap pathnames from generated sitemap.xml When sitemap plugins (e.g. @astrojs/sitemap) generate sitemap-index.xml, sitemap-0.xml, etc., these pathnames could leak into the aeo.js generated sitemap.xml as regular page URLs if they reach config.pages. Adds isSitemapPathname() guard to exclude any pathname starting with /sitemap from the generated sitemap. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/core/sitemap.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/sitemap.ts b/src/core/sitemap.ts index 13b5204..5306fa7 100644 --- a/src/core/sitemap.ts +++ b/src/core/sitemap.ts @@ -37,12 +37,17 @@ function escapeXml(str: string): string { .replace(/'/g, '''); } +function isSitemapPathname(pathname: string): boolean { + return /^\/sitemap/i.test(pathname); +} + export function generateSitemap(config: ResolvedAeoConfig): string { const urls: string[] = []; // Add discovered pages from framework plugin if (config.pages && config.pages.length > 0) { for (const page of config.pages) { + if (isSitemapPathname(page.pathname)) continue; urls.push(`${config.url}${page.pathname === '/' ? '' : page.pathname}`); } }