fix(router): keep "/" as the home path when the backend reports a langcode - #825
Conversation
🦋 Changeset detectedLatest commit: f97dd5e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe router no longer redirects ChangesRouter home-path handling
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The root home-path redirect fix is covered by focused tests, with no supported merge-blocking risk remaining. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #825 +/- ##
========================================
Coverage 81.79% 81.79%
========================================
Files 112 112
Lines 3054 3054
Branches 654 654
========================================
Hits 2498 2498
Misses 452 452
Partials 104 104
🚀 New features to boost your workflow:
|
c31eba5 to
f97dd5e
Compare
Closes #824.
DruxtRouter.getRedirect()now accepts/as the home path alongside/<langcode>and/<langcode>/. Any other path that resolves to the home path still redirects to the prefixed home path.isHomePathprops.langcode/en/en/eses/node/1es/es/esWhy
A backend can legitimately report a langcode for an unprefixed path. Entity routes always have, and the Views langcode patch (#3273228) makes Views routes do the same instead of returning
NULL. The router treated that as a wrong URL and bounced/to/en, a client side navigation that throws away the SSR-onlydata-fetch-keyattributes. That is what broke thedruxt-devel-template,multilingualandumami-homepagee2e specs inexamples/druxt-siteon #818.The redirect target still assumes the URL prefix equals the langcode. That is a separate bug and stays out of this PR.
Verification
packages/router/test/router.test.jsgains threegetRedirectcases. With the fix reverted and the test kept:Expected: false, Received: "/en". With the fix: 15 passed.druxt-routerpatch.Summary by CodeRabbit
/) could incorrectly redirect to a language-prefixed path.