Skip to content

fix(web): compare links with ?cat= open on their category - #1316

Merged
JOY (JOY) merged 2 commits into
devfrom
fix/1303-compare-cat-param
Oct 28, 2026
Merged

JOY (JOY) merged 2 commits into
devfrom
fix/1303-compare-cat-param

Conversation

@JOY

@JOY JOY (JOY) commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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's compareUrl and the side panel. The compare page read only ?category=, so those links opened on smartphones whenever no slugs set the category.

The page now reads both through compareCategoryParam (apps/web/src/lib/compare-params.ts). category wins 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: LeaderboardExplorer mixes cat and category in 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 normalize cat and category parameters and updates the compare page to use it.

🎯 Type of Change

  • 🚀 New feature
  • 🐛 Bugfix
  • 🧹 Refactor
  • ⚡ Performance
  • 📚 Documentation
  • ⚙️ CI / Configuration

🔍 Changes Walkthrough

File Summary of Changes
apps/web/package.json Added compare-params.test.ts to the test execution chain.
apps/web/src/lib/compare-params.ts New file. Exports compareCategoryParam which resolves the category from either category or cat query parameters, handling array inputs and empty strings.
apps/web/src/lib/__tests__/compare-params.test.ts New file. Unit tests verifying that category takes precedence over cat, and that cat is used when category is absent or empty.
apps/web/src/app/[locale]/compare/page.tsx Updated searchParams type to include cat. Replaced direct category extraction with the new compareCategoryParam utility 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
Loading

JOY (JOY) and others added 2 commits October 29, 2026 02:34
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>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

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.

@vercel

vercel Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
rate Ready Ready Preview Oct 28, 2026 7:36pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3a89ae70-c3dd-41bc-a43d-b60bea3fe5e2
Commits

Reviewing files that changed from the base of the PR and between 4eca23d and b70b8c0.

Files selected for processing: 4
  • apps/web/package.json
  • apps/web/src/app/[locale]/compare/page.tsx
  • apps/web/src/lib/__tests__/compare-params.test.ts
  • apps/web/src/lib/compare-params.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

dos[bot]
dos Bot approved these changes Oct 28, 2026

@dos dos Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱️ Code Review completed (4 eligible files · 12,306 chars · 1 model call(s) · 1 PR unit(s))

Whole diff with bounded context at base 4eca23d / head b70b8c0.

✅ CLEAN_PASS: Complete diff reviewed

@JOY
JOY (JOY) merged commit b1fd90d into dev Oct 28, 2026
20 checks passed
@JOY
JOY (JOY) deleted the fix/1303-compare-cat-param branch October 28, 2026 19:42

This branch was successfully deployed

1 active deployment
Preview — b70b8c09 Deployed Oct 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:frontend Frontend / Next.js / UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(web): compare links with ?cat= open on smartphones

1 participant