EPMRPP-113074 || Check root (/) in the sitemap#1078
EPMRPP-113074 || Check root (/) in the sitemap#1078maria-hambardzumian merged 5 commits intodevelopfrom
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughAdds Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
docusaurus.config.js (1)
43-50: Normalize pathname instead of concatenating on the full URL string.Current logic appends
/to the raw URL. If a future item includes query/hash, canonical URL formatting can break. Prefer normalizingpathnameviaURLand (optionally) deduping after normalization.♻️ Proposed refactor
createSitemapItems: async (params) => { const { defaultCreateSitemapItems, ...rest } = params; const items = await defaultCreateSitemapItems(rest); - return items.map((item) => ({ - ...item, - url: item.url.endsWith('/') ? item.url : `${item.url}/`, - })); + const seen = new Set(); + return items + .map((item) => { + const normalizedUrl = new URL(item.url); + if (!normalizedUrl.pathname.endsWith('/')) { + normalizedUrl.pathname = `${normalizedUrl.pathname}/`; + } + return { + ...item, + url: normalizedUrl.toString(), + }; + }) + .filter((item) => { + if (seen.has(item.url)) return false; + seen.add(item.url); + return true; + }); },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docusaurus.config.js` around lines 43 - 50, The sitemap item URL normalization currently appends '/' to item.url which can break when search or hash are present; in createSitemapItems, parse each item.url with the URL constructor (using params.siteUrl or a base) and normalize only the pathname to ensure a single trailing slash, then reconstruct the url using the normalized pathname plus the original search and hash (and optionally dedupe items after normalization); update the mapping in createSitemapItems to use this URL-based pathname normalization instead of simple string concatenation while keeping defaultCreateSitemapItems(params) and items variable usage.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@docusaurus.config.js`:
- Around line 43-50: The sitemap item URL normalization currently appends '/' to
item.url which can break when search or hash are present; in createSitemapItems,
parse each item.url with the URL constructor (using params.siteUrl or a base)
and normalize only the pathname to ensure a single trailing slash, then
reconstruct the url using the normalized pathname plus the original search and
hash (and optionally dedupe items after normalization); update the mapping in
createSitemapItems to use this URL-based pathname normalization instead of
simple string concatenation while keeping defaultCreateSitemapItems(params) and
items variable usage.
…nd consistent trailing slashes
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docusaurus.config.js`:
- Around line 50-53: The current hasFileExtension regex (/\.[a-zA-Z0-9]+$/)
treats numeric-dotted version slugs like "Version24.2.0" as having a file
extension and prevents trailing-slash normalization; update the check to only
treat true file extensions (alphabetic, typical short extensions) as
extensions—for example change hasFileExtension to use a stricter pattern like
/\.[a-zA-Z]{1,5}$/ (or otherwise match known extensions) so u.pathname for
versioned slugs will not be treated as having an extension and will receive the
trailing slash via the existing u.pathname += '/' logic.
Summary by CodeRabbit