Skip to content

fix: handle scoped packages named v#2280

Open
trivikr wants to merge 2 commits intonpmx-dev:mainfrom
trivikr:fix/parse-package-v-scope
Open

fix: handle scoped packages named v#2280
trivikr wants to merge 2 commits intonpmx-dev:mainfrom
trivikr:fix/parse-package-v-scope

Conversation

@trivikr
Copy link
Copy Markdown
Contributor

@trivikr trivikr commented Mar 26, 2026

🔗 Linked issue

N/A

🧭 Context

The package route parsers were treating the first path segment equal to v as the version delimiter. That works for normal package names, but it breaks scoped packages whose package segment is literally v, for example @scope/v.

A route like @scope/v/v/1.2.3 was being parsed incorrectly as:

  • package: @scope
  • version: v/1.2.3

instead of:

  • package: @scope/v
  • version: 1.2.3

This affected both the Nitro segment parser and the shared string parser used by docs/skills-style routes.

📚 Description

This PR fixes both parsers to recognize /v/ as a version delimiter only in the canonical npm package position:

  • after 1 segment for unscoped packages
  • after 2 segments for scoped packages

It also adds regression tests covering scoped packages whose package segment is literally v in both parser test suites.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 26, 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 26, 2026 6:58am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Mar 26, 2026 6:58am
npmx-lunaria Ignored Ignored Mar 26, 2026 6:58am

Request Review

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 26, 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!

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e7fdc103-548f-4757-b6df-a1a5cf7588d0

📥 Commits

Reviewing files that changed from the base of the PR and between 501e22f and f483bd8.

📒 Files selected for processing (2)
  • server/utils/parse-package-params.ts
  • shared/utils/parse-package-param.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • shared/utils/parse-package-param.ts
  • server/utils/parse-package-params.ts

📝 Walkthrough

Walkthrough

The pull request updates package parameter parsing in two utility modules to handle a specific edge case: when a path contains two consecutive 'v' segments (e.g., .../v/v/...), the parser advances to treat the second 'v' as the version delimiter. This required changing vIndex to be mutable and adding a conditional that increments it when the duplicated 'v' pattern is detected. Existing return shapes remain unchanged; the parser still returns package name and version only when a valid delimiter and following segment are present. Tests were added for scoped packages where the package name segment is literally 'v'.

Suggested reviewers

  • MatteoGabriele
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description clearly explains the bug being fixed: scoped packages with segment 'v' were incorrectly parsed, provides concrete examples of the problem and solution, and describes the changes to both parsers and added tests.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

1 participant