fix(start): strip trailing slash from prerenderable paths#7070
fix(start): strip trailing slash from prerenderable paths#7070restareaByWeezy wants to merge 1 commit intoTanStack:mainfrom
Conversation
inferFullPath preserves trailing slashes for index routes (e.g. /blog/) but the link crawler extracts paths without them (/blog). The seen Set treats these as distinct strings, so both get crawled and land in the sitemap as duplicates. Strip the trailing slash right after inferFullPath in getPrerenderablePaths so discovered paths match crawled ones.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe 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
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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. Comment |
Bundle Size Benchmarks
Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better. |
Fixes #6978
When using nested index routes like
blog/index.tsx, the prerender path discovery generates/blog/(with trailing slash) viainferFullPath, which intentionally preserves trailing slashes for index routes. But when the crawler picks up links from rendered HTML, it gets/blog(no trailing slash). TheseenSet inaddCrawlPageTaskuses exact string matching, so both pass dedup and end up as separate entries in the sitemap.The fix strips the trailing slash from
inferFullPathoutput ingetPrerenderablePathsbefore 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 callsinferFullPaththen 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,
/blogand/blog/are crawled separately. After, only/blogis crawled.Summary by CodeRabbit
Release Notes