Skip to content

fix: complex versions url handler#1718

Open
alex-key wants to merge 2 commits intonpmx-dev:mainfrom
alex-key:fix/dependencies-complex-versions
Open

fix: complex versions url handler#1718
alex-key wants to merge 2 commits intonpmx-dev:mainfrom
alex-key:fix/dependencies-complex-versions

Conversation

@alex-key
Copy link
Contributor

🔗 Linked issue

Resolves #1120

🧭 Context

On Package page for complex dependencies versions we need to resolve combination of multiple versions into a url containing a single version.

📚 Description

  • Added simple parsing logic to check any dependency version for being complex expression and provide a valid url.
  • By complex expression I mean: Range version, Union Version, Comparator Set version or combination of the above
  • Logic for extracting url is as follows:
    ^1.0.0 -> ^1.0.0 Simple
    1.0.0 || 2.0.0 -> 2.0.0 Union
    >1.0.0 <=2.0.0 -> <=2.0.0 Comparator Set
    1.0.0 - 2.0.0 -> 2.0.0 Range
    1.0.0 - 2.0.0 || 3.0.0 - 4.0.0 -> 4.0.0 Union of Ranges
  • dependencies, peerDependencies and optionalDependencies could have complex version (while 99% cases it's peer), so all of them are handled
  • at first I added multiple clickable links for Union separated by a delimiter "||" (1.0.0 || 2.0.0), but I think people rarely need to click on a specific version for union, also it would add some incosistency, so I keep it as a one link, which points to the latest version from Union

Examples for reference:
Comparator Set (dependencies): https://npmx.dev/package/sass
Comparator Set (peer): https://npmx.dev/package/styled-components/v/3.5.0-0
Union (dependencies): https://npmx.dev/package/normalize-package-data/v/2.5.0, https://npmx.dev/package/loose-envify/v/1.4.0
Union (peer): https://npmx.dev/package/eslint-plugin-react

@vercel
Copy link

vercel bot commented Feb 27, 2026

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

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Feb 27, 2026 9:17pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Feb 27, 2026 9:17pm
npmx-lunaria Ignored Ignored Feb 27, 2026 9:17pm

Request Review

@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 78.57143% with 3 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/components/Package/Dependencies.vue 78.57% 2 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2026

📝 Walkthrough

Walkthrough

This pull request refactors how dependency version strings are displayed and linked. A new VersionLink interface and buildVersionLink() function were introduced to handle complex semantic versioning syntax, including version unions (denoted with ||) and ranges (with operators like >=, <=). The Dependencies component was updated to transform version strings into structured objects containing both an href for valid routing and a title for display. Dependencies are now sorted alphabetically, and all template references have been updated to use the structured version object properties instead of raw version strings.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The PR description clearly relates to the changeset, explaining the complex version URL handling logic added to resolve issue #1120.
Linked Issues check ✅ Passed The PR successfully implements the core requirement from #1120: parsing complex version expressions (unions, ranges, comparator sets) and extracting a single valid URL instead of leaving encoded union strings that cause 404 errors.
Out of Scope Changes check ✅ Passed All changes are directly scoped to resolving #1120: the buildVersionLink utility function handles version parsing, and Dependencies.vue component integrates this parsing into dependency rendering.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 (1)
app/utils/versions.ts (1)

238-238: Consider removing && from the regex pattern.

The && operator is not part of the standard npm semver specification. Intersection (AND) in semver ranges is expressed using spaces, not &&. This condition would never match real npm version strings.

Suggested change
-  } else if (/>=|<=|[<>]|\s-\s|&&/.test(version)) {
+  } else if (/>=|<=|[<>]|\s-\s/.test(version)) {

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd566cb and b708b27.

📒 Files selected for processing (2)
  • app/components/Package/Dependencies.vue
  • app/utils/versions.ts

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.

Dependency links with version union ("1.0 || 2.0") resolves to 404 page

1 participant