Repository navigation
fix(web): compare links with ?cat= open on their category - #1316
Conversation
Links across the site and the extension write `/compare?cat=...` while the compare page read only `category`, so they opened on smartphones. The page now reads both; `category` wins when both are set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.
Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
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 |
Closes #1303
What changes
Links across the site and the extension write
/compare?cat=<category>: the leaderboard and versus API routes, the home page, the category page,LeaderboardExplorer,WatchlistWorkspace, the extension lookup'scompareUrland the side panel. The compare page read only?category=, so those links opened on smartphones whenever noslugsset the category.The page now reads both through
compareCategoryParam(apps/web/src/lib/compare-params.ts).categorywins when both are set, and an empty value counts as no value, as in the API routes. The fix sits on the page rather than the link builders because?cat=links already exist in shipped extension builds and public API answers.Tests
apps/web/src/lib/__tests__/compare-params.test.ts:cat,category, both, arrays, empty values. Web typecheck, lint and unit tests pass locally.Review
Fresh-context subagent: no P0-P2. P3s fixed: import placement, an empty value. One P3 left:
LeaderboardExplorermixescatandcategoryin two links, which is harmless now that both work.🤖 Generated with Claude Code
📌 TL;DR
This PR fixes a bug where compare links using the
?cat=query parameter failed to apply the correct category filter, causing them to default to smartphones. It introduces a new utility to normalizecatandcategoryparameters and updates the compare page to use it.🎯 Type of Change
🔍 Changes Walkthrough
apps/web/package.jsoncompare-params.test.tsto the test execution chain.apps/web/src/lib/compare-params.tscompareCategoryParamwhich resolves the category from eithercategoryorcatquery parameters, handling array inputs and empty strings.apps/web/src/lib/__tests__/compare-params.test.tscategorytakes precedence overcat, and thatcatis used whencategoryis absent or empty.apps/web/src/app/[locale]/compare/page.tsxsearchParamstype to includecat. Replaced directcategoryextraction with the newcompareCategoryParamutility to ensure links using?cat=work correctly.📊 Architectural Flow
flowchart TD A[Incoming Request] --> B{Query Params} B -->|?category=laptops| C[compareCategoryParam] B -->|?cat=earbuds| C B -->|?category=laptops&cat=earbuds| C C --> D{Resolution Logic} D -->|category exists & non-empty| E[Return 'laptops'] D -->|category empty/missing| F{Check cat} F -->|cat exists & non-empty| G[Return 'earbuds'] F -->|cat empty/missing| H[Return undefined] E --> I[Compare Page Component] G --> I H --> I