Skip to content

fix: correctly parse package name for scoped packages#2135

Open
gameroman wants to merge 2 commits intonpmx-dev:mainfrom
gameroman:fix-compare-page-scoped-package
Open

fix: correctly parse package name for scoped packages#2135
gameroman wants to merge 2 commits intonpmx-dev:mainfrom
gameroman:fix-compare-page-scoped-package

Conversation

@gameroman
Copy link
Contributor

@gameroman gameroman commented Mar 18, 2026

🔗 Linked issue

Fixes #2141

📚 Description

Fixes fetching data on compare page with scoped packages

Before

image

After

image

@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@vercel
Copy link

vercel bot commented Mar 18, 2026

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

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Mar 18, 2026 7:16pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Mar 18, 2026 7:16pm
npmx-lunaria Ignored Ignored Mar 18, 2026 7:16pm

Request Review

@gameroman gameroman changed the title fix: correctly parse package name for scoped packages [WIP] fix: correctly parse package name for scoped packages Mar 18, 2026
@gameroman gameroman marked this pull request as ready for review March 18, 2026 18:34
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 18, 2026

📝 Walkthrough

Walkthrough

This pull request adds URI decoding to two API route handlers for package registry endpoints (analysis and install-size) by applying decodeURIComponent to the raw package name parameter before parsing. Additionally, it introduces unit tests for the parsePackageParams utility function, covering scenarios with unscoped and scoped packages both with and without versions. The changes ensure that encoded package names in route parameters are correctly decoded prior to validation and parsing.

Possibly related PRs

Suggested labels

needs review

Suggested reviewers

  • danielroe
  • serhalp
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code changes decode URI-encoded package names in two API endpoints and add comprehensive unit tests for parsePackageParams, directly addressing the scoped package handling requirement from issue #1.
Out of Scope Changes check ✅ Passed All changes are focused on fixing scoped package name parsing: two API endpoint modifications and corresponding unit tests directly address the linked issue without introducing extraneous modifications.
Description check ✅ Passed The pull request description clearly relates to the changeset, describing the fix for scoped package parsing on the compare page with visual before/after demonstrations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
server/api/registry/analysis/[...pkg].get.ts (1)

38-46: Consider extracting route package-param parsing into a shared helper.

This block is now duplicated across endpoints; centralising it would lower future drift risk when parsing/decoding rules change.

test/unit/server/utils/parse-package-params.spec.ts (1)

4-53: Useful parser coverage; add one regression test for encoded route input.

These tests validate segment parsing well, but the bug fix is in handler decoding. Please add a handler-level test with %40scope%2Fname so the original regression is fully guarded.

As per coding guidelines **/*.{test,spec}.{ts,tsx}: Write unit tests for core functionality using vitest.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a276c004-28ce-491f-b50c-2f60a4d5f279

📥 Commits

Reviewing files that changed from the base of the PR and between 77c4570 and 2c0f0cb.

📒 Files selected for processing (3)
  • server/api/registry/analysis/[...pkg].get.ts
  • server/api/registry/install-size/[...pkg].get.ts
  • test/unit/server/utils/parse-package-params.spec.ts

@MatteoGabriele
Copy link
Contributor

@gameroman, could you provide a more detailed description of what this PR aims to fix? The issue you mentioned links to a ticket on your fork, and there are only two links. It's a bit cryptic, even for future reference, and it would be better documented/tracked in this repository.

@gameroman
Copy link
Contributor Author

@gameroman, could you provide a more detailed description of what this PR aims to fix? The issue you mentioned links to a ticket on your fork, and there are only two links. It's a bit cryptic, even for future reference, and it would be better documented/tracked in this repository.

Updated

@MatteoGabriele
Copy link
Contributor

Judging by the title, I expected to see some artifacts in the stats, but they look the same unless I'm missing something.

Screenshot 2026-03-18 at 22 28 11

@gameroman
Copy link
Contributor Author

gameroman commented Mar 18, 2026

@MatteoGabriele
Copy link
Contributor

@MatteoGabriele
Copy link
Contributor

btw I like the addition. I was wondering if it wouldn't make sense to include it directly within the parsePackageParams utility and add tests for when the string is actually encoded? What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stats on compare page fail to load for scoped packages

2 participants