Skip to content

Add ComparisonForm for per-ecosystem package identity - #50

Merged
andrew merged 1 commit into
git-pkgs:mainfrom
simonchrz:feat/comparison-form
Oct 24, 2026
Merged

andrew merged 1 commit into
git-pkgs:mainfrom
simonchrz:feat/comparison-form

Conversation

@simonchrz

Copy link
Copy Markdown
Contributor

Adds PURL.ComparisonForm(), which returns a copy of a PURL in a form where two spellings of the same package compare equal:

  • pypi: PEP 503 names, so zope.interface, zope_interface and Zope-Interface match
  • nuget: lowercase ids and versions
  • composer: versions without a leading v
  • conda: the channel in the channel qualifier, whether it was written as namespace or as channel/name
  • oci: repository paths as one name
  • swift: lowercase registry identities

Parse and String are unchanged, so nothing that stores PURL strings is affected. These rules currently live in git-pkgs/proxy (git-pkgs/proxy#563), which will switch to this once it is released.

Parse canonicalises only what packageurl-go does, so spellings such as
pkg:pypi/zope.interface and pkg:pypi/zope_interface, or mixed-case NuGet
ids, still compare unequal. ComparisonForm applies the remaining
ecosystem rules (PEP 503, NuGet case, Composer's leading v, conda
channel, OCI repository paths, Swift registry identity case) without
changing what Parse or String return.
@andrew
andrew merged commit 2a1e0a9 into git-pkgs:main Oct 24, 2026
3 checks passed
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.

2 participants