-
Notifications
You must be signed in to change notification settings - Fork 0
feat: improve redirects with splat patterns and case-insensitive matching #246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe PR expands anchor redirect mappings (stored in ANCHOR_REDIRECTS), normalises path matching to lowercase, and adjusts redirect construction for relative anchor targets. It replaces many explicit static/_redirects entries with splat-based redirect rules. test-all-urls.js was extended with many more redirect cases, added throttling, case-insensitive final-URL checks, and richer logging. Several SDK-API MDX documentation pages and a sidebar export were removed. Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
✅ Deploy Preview for absmartly-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…hing - Consolidate server redirects using Netlify splat patterns (~75 rules vs 169) - Make anchor redirects case-insensitive to avoid duplication - Add anchor redirects for pages with changed section headings - Remove case-only redirects that could cause infinite loops - Update test script with comprehensive redirect tests
41574d6 to
4a5c824
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
test-all-urls.js (1)
22-40: Align throttling docs with the configured delay.
The header says 200ms butTHROTTLE_MSis 25ms. Please align the comment or the constant to avoid confusion when tuning rate limits.📝 Example fix (if 25ms is intended)
- * 5. Throttles requests (200ms delay) to avoid rate limiting + * 5. Throttles requests (25ms delay) to avoid rate limiting
🤖 Fix all issues with AI agents
In `@static/_redirects`:
- Around line 9-13: The splat redirect rules for `/docs/SDK-Documentation/*` and
`/docs/sdk-documentation/*` don't catch the bare base paths without trailing
slashes; add explicit redirect lines for `/docs/SDK-Documentation` ->
`/docs/APIs-and-SDKs/SDK-Documentation 302` and `/docs/sdk-documentation` ->
`/docs/APIs-and-SDKs/SDK-Documentation 302` (and also add explicit
`/docs/SDK-Documentation/Advanced` ->
`/docs/APIs-and-SDKs/SDK-Documentation/Advanced 302` and
`/docs/sdk-documentation/advanced` ->
`/docs/APIs-and-SDKs/SDK-Documentation/Advanced 302` if you want the Advanced
base paths covered) so the base paths are redirected in addition to the existing
splat rules.
🧹 Nitpick comments (1)
test-all-urls.js (1)
498-525: Treat non‑2xx final responses as redirect failures.
At the moment, a redirect that lands on a 404 can still pass if the final path matches. Folding the final status intomatchavoids false positives, especially when running with--only-failed.✅ Proposed adjustment
- const finalUrl = page.url(); - const finalPath = finalUrl.replace(BASE_URL, ''); + const finalUrl = page.url(); + const finalPath = finalUrl.replace(BASE_URL, ''); + const statusCode = response.status(); + const ok = statusCode >= 200 && statusCode < 300; - // Case-insensitive comparison (Netlify may lowercase URLs) - const match = normalizedFinal === normalizedExpected; + // Case-insensitive comparison (Netlify may lowercase URLs) + const match = ok && normalizedFinal === normalizedExpected; return { - success: true, + success: ok, match, fromPath, expectedPath: expectedToPath, finalPath, - statusCode: response.status() + statusCode };
The files were incorrectly copied instead of renamed during a previous merge. Removing the old docs/SDK-API/ directory so redirects work properly. Files already exist in docs/APIs-and-SDKs/SDK-API/.
Splat patterns (/*) don't match bare paths without trailing slash. Added explicit redirects for: - /docs/SDK-Documentation and /docs/SDK-Documentation/Advanced - /docs/sdk-documentation and /docs/sdk-documentation/advanced - /docs/Examples and /docs/examples - /docs/API, /docs/sdk-api, /docs/SDK-API - /docs/web-console-api and /docs/Web-Console-API
Summary
Test plan
node test-all-urls.js <deploy-preview-url>to verify all redirects workSummary by CodeRabbit
Bug Fixes
Improvements
Tests
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.