Skip to content

fix(crawler): pages stored under absolute URLs; relative sitemap loc resolved and reported #1274 - #1295

Closed
nc9 wants to merge 1 commit into
mainfrom
fix/1274-relative-urls
Closed

nc9 wants to merge 1 commit into
mainfrom
fix/1274-relative-urls

Conversation

@nc9

@nc9 nc9 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #1274

What

Root cause: the crawler stored page.url = entry.rawUrl, the URL as discovered. A relative sitemap <loc>/pricing</loc> was enqueued fine (the frontier resolves it against the base for fetching), but the page record kept the raw /pricing, so new URL(ctx.page.url) threw in url/length, url/parameters, url/slug-keywords, url/trailing-slash, crawl/pagination and schema/website-search on every page.

  • enqueueUrl (packages/crawler/src/core/crawler.ts) now stores the absolute URL, resolved against the crawl base exactly as normalizeUrl already did, so no discovery source (sitemap, link, carried, seed) can put a path into a page record.
  • parseSitemap resolves a relative <loc> (urlset or index child) against the sitemap's own URL, so sitemap-coverage matching sees the page it names, and records one error per sitemap listing the offending entries ("N values are not an absolute URL ..."). crawl/sitemap-valid already surfaces sitemap.errors, so the protocol problem is reported there with the entries listed, no new rule or check.
  • The relative Sitemap: line in robots.txt was already resolved (Seed redirect probe and cache Vary key should use the custom User-Agent header when one is set #2316); unchanged.

Tests (failing first)

packages/crawler/tests/relative-urls-1274.test.ts: parseSitemap resolves and reports relative locs (urlset and index) and stays silent for absolute ones; a real crawl of a Bun.serve fixture with a relative-loc sitemap and a scheme-less link stores only absolute, parseable page URLs. 3 of 4 failed on main.

Built CLI (squirrel audit on a fixture with Sitemap: /sitemap.xml and <loc>/</loc>, --offline --passive): 15 Rule error: Invalid URL fails on main, 0 after; crawl/sitemap-valid lists /, /pricing.

Not covered

  • AC "a rule that throws reports once per rule, not per page": that is rule-error reporting in general, filed as runner: a rule that throws on every page reports one fail per page and lowers the score; report it once as not evaluated #1291 (the AC allows the link). With this fix no rule throws on these pages.
  • The "Site B" scheme-less case (https://example.com/other-host.azurewebsites.net/apps/x) is already a valid absolute URL after resolution; the same admission fix covers any raw form that failed.
  • Skill (squirrelscan/skills): no change needed. No docs change (no new check or reason).
  • CHANGELOG bullet under ## [Unreleased] / Fixed.

…<loc> resolved and reported #1274

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9 nc9 mentioned this pull request Oct 30, 2026
@nc9

nc9 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Landed in v0.0.142 via the stacked release PR #1331: 527e54a2 and the commits after it on main (rebase-merged, so this PR shows as closed rather than merged).

@nc9 nc9 closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Relative sitemap <loc> / scheme-less links reach the rules as page URLs: 6 URL rules fail with 'Invalid URL' on every page

1 participant