Skip to content

Universal SEO skill for Claude Code. 26 sub-skills + 19 sub-agents covering technical SEO, E-E-A-T, schema, GEO/AEO, agent readiness (Lighthouse Agentic Browsing, WebMCP, llms.txt), backlinks, local SEO, e-commerce, international SEO, Google APIs, and PDF/Excel reporting. 9 optional extensions for live SEO data.

fix(sitemap): keep Sitemap URLs when a comment follows

Rudy Celekli748129673d8e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 648be42..0f33d8e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Fixed
+
+- **Sitemap discovery keeps a robots.txt URL when a comment follows it.**
+ `Sitemap: https://example.com/products.xml # catalog` was dropped, so that
+ URL was never fetched and only the common paths were checked. A `#` comment
+ runs to the end of the line (Google's robots.txt syntax, and RFC 9309), and
+ a leading UTF-8 BOM is not part of the first field.
+
## [2.5.0] - 2026-10-22
Security and accuracy fixes from a full audit, and Claude Desktop installs again.
diff --git a/scripts/sitemap_discovery.py b/scripts/sitemap_discovery.py
index 9ee766c..db53e6e 100644
--- a/scripts/sitemap_discovery.py
+++ b/scripts/sitemap_discovery.py
@@ -105,9 +105,18 @@ def _bounded_fetch(url: str, max_bytes: int) -> dict:
def _robots_sitemaps(content: bytes) -> list[str]:
+ """Return Sitemap URLs declared in a robots.txt body.
+
+ Google's robots.txt syntax is ``field:value`` with an optional ``#``
+ comment through the end of the line. The comment is not part of the URL.
+ A leading UTF-8 BOM is an encoding signature, not part of the first field.
+ """
text = content.decode("utf-8", errors="replace")
+ if text.startswith("\ufeff"):
+ text = text[1:]
found = []
for line in text.splitlines():
+ line = line.split("#", 1)[0]
match = _SITEMAP_LINE.match(line)
if match and match.group(1) not in found:
found.append(match.group(1))
diff --git a/tests/test_sitemap_discovery.py b/tests/test_sitemap_discovery.py
index 0bf3319..bafeec8 100644
--- a/tests/test_sitemap_discovery.py
+++ b/tests/test_sitemap_discovery.py
@@ -158,3 +158,40 @@ def test_private_literal_is_refused_before_network_request():
def test_invalid_port_is_reported_without_crashing():
result = discovery.discover_sitemaps("https://example.com:invalid/")
assert result["error"] == "Target URL contains an invalid port"
+
+
+def test_sitemap_directive_keeps_its_url_when_a_comment_follows():
+ """Google's robots.txt syntax ignores everything after #. The URL stays."""
+ declared = "https://example.com/products.xml"
+ robots = (
+ f"User-agent: *\nSitemap: {declared} # primary catalog\n"
+ f"# Sitemap: https://example.com/secret.xml\n"
+ ).encode()
+ assert discovery._robots_sitemaps(robots) == [declared]
+
+
+def test_sitemap_directive_on_the_first_line_survives_a_utf8_bom():
+ declared = "https://example.com/products.xml"
+ robots = b"\xef\xbb\xbf" + f"Sitemap: {declared}\n".encode()
+ assert discovery._robots_sitemaps(robots) == [declared]
+
+
+def test_commented_sitemap_directive_is_the_url_that_gets_fetched():
+ declared = "https://example.com/products.xml"
+ fetched = []
+
+ def fake_fetch(url, _limit):
+ fetched.append(url)
+ if url.endswith("robots.txt"):
+ return response(
+ content=f"User-agent: *\nSitemap: {declared} # primary catalog\n".encode(),
+ content_type="text/plain",
+ )
+ if url == declared:
+ return response(content=URLSET, url=url)
+ return response(status=404, url=url)
+
+ with patch.object(discovery, "_bounded_fetch", side_effect=fake_fetch):
+ result = discovery.discover_sitemaps("https://example.com")
+ assert declared in fetched
+ assert [item["url"] for item in result["found"] if item["url"] == declared] == [declared]