Fixes #6978
When using nested index routes like blog/index.tsx, the prerender path discovery generates /blog/ (with trailing slash) via inferFullPath, which intentionally preserves trailing slashes for index routes. But when the crawler picks up links from rendered HTML, it gets /blog (no trailing slash). The seen Set in addCrawlPageTask uses exact string matching, so both pass dedup and end up as separate entries in the sitemap.
The fix strips the trailing slash from inferFullPath output in getPrerenderablePaths before adding to the Set. This way discovered paths match crawled paths and the dedup works correctly. Root path / is kept as-is.
This is consistent with how inferTo (same package, unexported) already handles paths -- it calls inferFullPath then strips the trailing slash, since prerender paths are URLs rather than type identifiers.
Tested against the reproduction repo from the issue (https://github.com/dotnize/start-static-test). Before this change, /blog and /blog/ are crawled separately. After, only /blog is crawled.
Summary by CodeRabbit#
Release Notes#
- Bug Fixes
- Fixed path normalization in the prerender process to ensure consistent route path handling. Non-root routes now have trailing slashes removed for consistency, while the root path remains unchanged, improving path storage reliability.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID:
7d73841b-2061-4fcc-8e71-ea7af1ae9af9📥 Commits
Reviewing files that changed from the base of the PR and between 30835cb8e935b740c92fa95909a073e644dde530 and d4166bc1622dc6eb337bc53ea5adfd42ea750901.
📒 Files selected for processing (1)
packages/start-plugin-core/src/start-router-plugin/generator-plugins/prerender-routes-plugin.ts📝 Walkthrough
Walkthrough#
The prerender routes plugin now normalizes collected inferred route paths by removing trailing slashes from non-root paths, ensuring consistent path storage without terminal slashes in the prerender list.
Changes#
packages/start-plugin-core/src/start-router-plugin/generator-plugins/prerender-routes-plugin.ts'/'is preserved as-is. This ensures consistent path representation without duplicate slash variants.Estimated code review effort#
🎯 1 (Trivial) | ⏱️ ~3 minutes
Poem#
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
#6978where nested index routes produced duplicate entries differing only by trailing slash.#6978.✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share